Windchill REST Services Domain Capabilities > Windchill Subtypes in OData
Windchill Subtypes in OData
This section explains how to create Windchill subtypes in OData and perform a search on Windchill subtypes.
You can create Windchill subtypes in OData using,
The odata.type annotation
Typecasting
To create a Windchill subtype in OData, the odata.type value or the typecast segment must contain the fully qualified name of the entity or subtype entity. A fully qualified name of an entity is the entity name along with the Namespace value. For example, if PTC.ProdMgmt is the namespace, and the entity name is ElectricalPart, the fully qualified name of the entity is PTC.ProdMgmt.ElectricalPart.
* 
You cannot use Windchill type name in the value specified for the odata.type annotation.
You must specify the exact entity name, which is defined while configuring the entity, in the fully qualified name of the entity.
To get the exact OData entity name, refer to the domain EDM available at its metadata URL.
Creating a Windchill Subtype Using the “odata.type” Annotation
To create a Windchill subtype using the odata.type annotation, you must use the odata.type annotation in the request body of the HTTP request.
* 
You can use the odata.type annotation in actions and entity sets.
For example, to create an instance of Windchill soft type com.ptc.ElectricalPart using Windchill REST Services, specify the odata.type annotation in the request body of the POST URI as follows.
URI
POST /Windchill/servlet/odata/ProdMgmt/Parts
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"Name": "An Electrical Part from WRS",
"Number": "WRSEP0001",
"AssemblyMode": {
"Value": "separable",
"Display": "Separable"
},
"DefaultUnit": {
"Value": "ea",
"Display": "Each"
},
"EndItem": false,
"DefaultTraceCode": {
"Value": "0",
"Display": "Untraced"
},
"Source": {
"Value": "make",
"Display": "Make"
},
"ConfigurableModule": {
"Value": "standard",
"Display": "No"
},
"View": "Design",
"GatheringPart": false,
"PhantomManufacturingPart": false,
"@odata.type": "#PTC.ProdMgmt.ElectricalPart",
"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:125142')"
}
Creating a Windchill Subtype Using Typecasting
To create a Windchill subtype in OData using typecasting you can use the typecast segment, which contains the fully qualified name of the subtype entity, in the HTTP request URI.
* 
Append the typecast segment to an entity set to create Windchill subtypes using typecasting.
For example, to create an instance of Windchill soft type com.ptc.ElectricalPart using Windchill REST Services, use the Parts/PTC.ProdMgmt.ElectricalPart typecast in the POST URI as follows.
URI
POST /Windchill/servlet/odata/ProdMgmt/Parts/PTC.ProdMgmt.ElectricalPart
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"Name": "Test electrical part1",
"Number": "ElectricalPart1",
"AssemblyMode": {
"Value": "separable",
"Display": "Separable"
},
"DefaultUnit": {
"Value": "ea",
"Display": "Each"
},
"EndItem": false,
"DefaultTraceCode": {
"Value": "0",
"Display": "Untraced"
},
"Source": {
"Value": "make",
"Display": "Make"
},
"ConfigurableModule": {
"Value": "standard",
"Display": "No"
},
"View": "Design",
"GatheringPart": false,
"PhantomManufacturingPart": false,
"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:125119')"
}
Searching on Windchill Subtypes
To perform a search only on Windchill subtypes, you can append the typecast segment to an entity set in the HTTP request URI.
To search only for the com.ptc.ElectricalPart Windchill soft type, use filter on the PTC.ProdMgmt.ElectricalPart typecast segment in the GET URI as follows. For example,
URI
GET /Windchill/servlet/odata/ProdMgmt/Parts/PTC.ProdMgmt.ElectricalPart?$filter=startswith(Number,'EP')&$select=Name,Number,Version
To perform a search on Windchill subtypes to retrieve specific objects, you can also use the typecast segment in navigations in the HTTP request URI.
For example, to retrieve only the change notices related to a change request, expand on the ProcessObjects/PTC.ChangeMgmt.ChangeNotice navigation, which contains the PTC.ChangeMgmt.ChangeNotice typecast segment, in the GET URI as follows. For example,
URI
GET /Windchill/servlet/odata/ChangeMgmt/ChangeRequests('OR:wt.change2.WTChangeRequest2:292348')?$select=Identity,Name&$expand=ProcessObjects/PTC.ChangeMgmt.ChangeNotice($select=Identity,Name)