Skip to main content
Jul 31, 2019 5:54 AM UTC
Solved

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 ?

 

fivigAnswer
Jul 31, 2019 6:55 AM UTC

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.

4 replies

fivigAnswer
Jul 31, 2019 6:55 AM UTC

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.
Aug 2, 2019 4:24 AM UTC

 Thanks @unknown  

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 ?

 

Aug 2, 2019 4:28 AM UTC

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?