cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

How to Create WTPart of a specific subType using REST API ?

shindemayur
14-Alexandrite

How to Create WTPart of a specific subType using REST API ?

Hello,

         I want to create a WTPart part object using Rest API. This is possible, but I am not able to provide a specific subtype name. I can not found any Odata for that.

Can any one help me with an example to create part of subtype using REST API ?

 

ACCEPTED SOLUTION

Accepted Solutions

Hello,

 

add attribute to your json file, e.g  "@odata.type": "#PTC.ProdMgmt.ElectricalPart",

 

This body work fine:

 

 {
"@odata.context": "http://wnc_host/Windchill/servlet/odata/v3/ProdMgmt/$metadata#Parts",
"@odata.type": "#PTC.ProdMgmt.ElectricalPart",
"AlternateNumber": null,
"AssemblyMode": {
"Value": "separable",
"Display": "Separable"
},
"BOMType": null,
"CabinetName": "Default",
"ChangeStatus": null,
"CheckOutStatus": "",
"CheckoutState": "Checked in",
"Comments": null,
"ConfigurableModule": {
"Value": "standard",
"Display": "No"
},
"CreatedBy": "Demo, User",
"DefaultTraceCode": {
"Value": "0",
"Display": "Untraced"
},
"DefaultUnit": {
"Value": "ea",
"Display": "each"
},
"EndItem": false,
"FolderLocation": "/Drive System",
"FolderName": null,
"GatheringPart": false,
"GeneralStatus": null,
"Latest": true,
"LifeCycleTemplateName": "Basic",
"Name": "test1",
"Number": "TEST1",
"OEMPartSourcingStatus": [],
"ObjectType": "Electrical Part",
"OrganizationReference": "{\"type\":\"text\"}",
"PhantomManufacturingPart": false,
"Revision": "A",
"ShareStatus": null,
"Source": {
"Value": "make",
"Display": "Make"
},
"State": {
"Value": "INWORK",
"Display": "In Work"
},
"Supersedes": null,
"TypeIcon": {
"Path": "http://wnc_host/Windchill/wtcore/images/part.gif",
"Tooltip": "Electrical Part"
},
"View": "Design",
"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:85642')"
}

 

Next time:

  1. Create an object manually 
  2. Query it with REST service
  3. Review output from the response query and use necessary attributes.

View solution in original post

4 REPLIES 4

Hello,

 

add attribute to your json file, e.g  "@odata.type": "#PTC.ProdMgmt.ElectricalPart",

 

This body work fine:

 

 {
"@odata.context": "http://wnc_host/Windchill/servlet/odata/v3/ProdMgmt/$metadata#Parts",
"@odata.type": "#PTC.ProdMgmt.ElectricalPart",
"AlternateNumber": null,
"AssemblyMode": {
"Value": "separable",
"Display": "Separable"
},
"BOMType": null,
"CabinetName": "Default",
"ChangeStatus": null,
"CheckOutStatus": "",
"CheckoutState": "Checked in",
"Comments": null,
"ConfigurableModule": {
"Value": "standard",
"Display": "No"
},
"CreatedBy": "Demo, User",
"DefaultTraceCode": {
"Value": "0",
"Display": "Untraced"
},
"DefaultUnit": {
"Value": "ea",
"Display": "each"
},
"EndItem": false,
"FolderLocation": "/Drive System",
"FolderName": null,
"GatheringPart": false,
"GeneralStatus": null,
"Latest": true,
"LifeCycleTemplateName": "Basic",
"Name": "test1",
"Number": "TEST1",
"OEMPartSourcingStatus": [],
"ObjectType": "Electrical Part",
"OrganizationReference": "{\"type\":\"text\"}",
"PhantomManufacturingPart": false,
"Revision": "A",
"ShareStatus": null,
"Source": {
"Value": "make",
"Display": "Make"
},
"State": {
"Value": "INWORK",
"Display": "In Work"
},
"Supersedes": null,
"TypeIcon": {
"Path": "http://wnc_host/Windchill/wtcore/images/part.gif",
"Tooltip": "Electrical Part"
},
"View": "Design",
"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:85642')"
}

 

Next time:

  1. Create an object manually 
  2. Query it with REST service
  3. Review output from the response query and use necessary attributes.

 Thanks @ivan_feofilov  

This work fine while creating a Electrical Part, but it fails while creating a any other sub Type part.

 

e.g. My Sub Type name is com.globematics.REParts,

So,

"@odata.context": "http://devapp2.globematics.com/Windchill/servlet/odata/v1/ProdMgmt/$metadata#Parts",
"@odata.type": "#PTC.ProdMgmt.REParts",

 

but, this is not working. custom created sub types can't be used ?

 

Next time:

  1. Create an object manually 
  2. Query it with REST service
  3. Review output from the response query and use necessary attrib

Can you try to use custom subtype WTPart format from a query?

yes @ivan_feofilov , its working.

Thanks for your support.

Announcements

Top Tags