Skip to main content
1-Visitor
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
5-Regular Member

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

fivig5-Regular MemberAnswer
5-Regular Member

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.
Translate
1-Visitor

 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 ?

 

Translate
5-Regular Member

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?

Translate