Windchill REST Services > Windchill REST Services Framework Capabilities > Support for OData > OData Query Parameters > Examples for OData Query Parameters
  
Examples for OData Query Parameters
The following examples demonstrate how to use query parameters:
GET request:
ProdMgmt/Parts?$filter=startswith(Number, '00')
The response shows only those parts that start with '00' in the entity set.
GET request:
ProdMgmt/Parts('OR:wt.part.WTPart:992345')/Uses?$filter=Quantity eq 1&$top=1
The response shows the first PartUse entity from the top of the collection that has Quantity equals to one.
GET request:
ProdMgmt/Parts('OR:wt.part.WTPart:992345')/UsedBy?$filter=ID eq 'OR:wt.part.WTPart:999999'&$select=Name
The response shows the ID and Name of the OR:wt.part.WTPart:999999 part. This denotes that OR:wt.part.WTPart:992345 is used by the part OR:wt.part.WTPart:999999.
GET request:
ProdMgmt/Parts('OR:wt.part.WTPart:999999')?$expand=Uses($select=ID;$filter=ID eq 'OR:wt.part.WTPartUsageLink:260222')&$select=Name
The response shows the ID and Name of the specified part along with the usage link ID equals to OR:wt.part.WTPartUsageLink:260222.
GET request:
ProdMgmt/Parts?$filter=ID eq 'OR:wt.part.WTPart:112022'
The response shows information about the part with ID equals to 'OR:wt.part.WTPart:112022' in the entity set.
GET request:
ProdMgmt/Parts?$filter=ID ne 'OR:wt.part.WTPart:112022'
The response shows information about all the parts in the entity set excluding the part with ID equals to 'OR:wt.part.WTPart:112022'.
GET request:
PrincipalMgmt/Users?$filter=ID eq 'OR:wt.org.WTUser:11'
The response shows information about the user with ID equals to 'OR:wt.org.WTUser:11'.
GET request:
ProdMgmt/Parts?$filter=CreatedBy eq 'Demo, User'
The response shows information about the parts that are created by the user 'Demo, User' in the entity set.
GET request:
ProdMgmt/Parts?$filter=View eq 'Service'&ptc.search.latestversion=true
The response shows information about the parts of only the latest version and of the 'Service' view in the entity set.
* 
Empty or null search is not supported for the View property. For example, the following GET request returns an error:
ProdMgmt/Parts?$filter=View eq ''&ptc.search.latestversion=true
The example below shows how to perform a wildcard (*) search on the structural properties of an entity. Set “PTC-WildcardSearch” to true in the request header to enable wildcard search.
GET request:
ProdMgmt/Parts?$filter=Name eq 'Golf*'
The response shows all the parts with Name equal to the value that matches the wildcard search criteria, that is, Golf*.
* 
Wildcard filtering only supports eq, ne, startswith, endswith, and contains.
Wildcard filtering is not supported for actions, functions, navigation properties, enum and complex types.
GET request:
ProdMgmt/Parts?$expand=Uses($select=Quantity,TraceCode;$filter= Quantity gt 1)
Send this request to the server when you want to expand the Uses navigation to only show the Quantity and TraceCode properties of PartUse entities that have quantity greater than one.
GET request:
ProdMgmt/Parts('OR:wt.part.WTPart:99999')/Uses?$orderby=Quantity
The response sorts the PartUse entities in ascending order of quantity.
GET request:
ProdMgmt/Parts('OR:wt.part.WTPart:99999')/Uses?$orderby=CreatedOn,Quantity
The response first sorts the PartUse entities in ascending order of the dates on which the entities were created and then by quantity. When entities have the same CreatedOn dates and different quantities, the entities are sorted by Quantity. When entities have different CreatedOn dates, the entities are sorted only by the date property.
GET request:
ProdMgmt/Parts?$orderby=ID desc&$select=ID,Name
The response shows ID and Name of the parts while sorting the parts in descending order of ID.
GET request:
ProdMgmt/Parts?$orderby=ModifiedBy asc&$select=ID,Name,ModifiedBy
The response shows the ID, Name, and ModifiedBy attributes of the parts while sorting the parts in ascending order of ModifiedBy.
GET request:
ProdMgmt/Parts('OR:wt.part.WTPart:99999')/Uses?$orderby=ID asc&$select=ID
The response shows the usage links for the specified part in the entity set. The usage links are sorted in ascending order based on the ID property.
GET request:
DocMgmt/Documents?$filter=startswith(Name,'Demo')&$orderby=ZipCodeIn asc&$top=2
The response shows the top two documents whose names start with Demo. The documents are sorted in ascending order of ZipCodeIn.
GET request:
ProdMgmt/Parts('OR:wt.part.WTPart:897988')/UsedBy?$count=true
This example shows UsedBy navigation. The navigation is available on the Part entity. The response returns the count as "@odata.count": 2.
{
"@odata.context": "//Windchill/servlet/odata/ProdMgmt/$metadata#Parts",
"@odata.count": 2,
"value": [
{
"@odata.type": "#PTC.ProdMgmt.Part",
"ID": "OR:wt.part.WTPart:897456",
...
},
{
"@odata.type": "#PTC.ProdMgmt.Part",
"ID": "OR:wt.part.WTPart:897234",
...
}
]
}
GET request:
ProdMgmt/Parts?$expand=UsedBy($count=true)
This example is created for expanding the UsedBy navigation. The navigation is available on the Part entity. The response returns the count as UsedBy@odata.count": 2.
{
"@odata.context": "//Windchill/servlet/odata/ProdMgmt/$metadata#Parts",
"value": [
{
"@odata.type": "#PTC.ProdMgmt.Part",
"ID": "OR:wt.part.WTPart:89798",
...
"UsedBy@odata.count": 2,
"UsedBy": [
{
"@odata.type": "#PTC.ProdMgmt.Part",
"ID": "OR:wt.part.WTPart:897456",
...
},
{
"@odata.type": "#PTC.ProdMgmt.Part",
"ID": "OR:wt.part.WTPart:897234",
...
}
]
}
]
}
GET request:
ProdMgmt/Parts('<OID>')?$expand=PartDocAssociations($filter=AssociationType/Value eq PTC.CADDocumentMgmt.AssociationTypeEnum'CALCULATED')
Send this request to the server when you want to expand the PartDocAssociations navigation to only show the associations that have the AssociationType property with value equals to CALCULATED.
GET request:
ProdMgmt/Parts('<OID>')/PartDocAssociations?$expand=RelatedCADDoc($select=Identity)&$filter=RelatedCADDoc/Category/Value eq 'CADDRAWING'
Send this request to the server when you want to expand the RelatedCADDoc navigation to show the Identity property and only the RelatedCADDoc and Category properties with value equals to CADDRAWING for the related CAD documents.
GET request:
CADDocumentMgmt/CADDocuments('<OID>')?$expand=PartDocAssociations($filter=AssociationType/Value eq PTC.CADDocumentMgmt.AssociationTypeEnum'CALCULATED')
Send this request to the server when you want to expand the PartDocAssociations navigation to only show the associations that have the AssociationType property with value equals to CALCULATED.
GET request:
CADDocumentMgmt/CADDocuments('<OID>')?$select=Name,Number,FileName&$expand=PartDocAssociations($orderby=AssociationType/Value;$filter=AssociationType/Value eq PTC.CADDocumentMgmt.AssociationTypeEnum'CALCULATED';$expand=RelatedPart($select=Number,Name,Version))
Send this request to the server when you want to expand the PartDocAssociations navigation to only show the associations that have the AssociationType property with value equals to CALCULATED and to further expand to the related part of the calculated association.
GET request:
ProdMgmt/Parts('<OID>')/Attachments('<OID>')?$select=FormatIcon,LastModifed,PTC.ApplicationData/MimeType
The response shows the FormatIcon, LastModifed, and MimeType attributes for the specific attachment to the part.
* 
You must use PTC.ApplicationData/<attribute> in the request URI when you use $select or $filter on the Content, FileName, FileSize, Format, or MimeType attributes.
GET request:
GET /Visualization/Representations(<oid>)/BoundingBox?$count=true
This example shows the $count query option for the Primitives type collection. The response is:
{
"@odata.context": https://<Windchill>/servlet/odata/v3/Visualization/$metadata#Representations/BoundingBox,
"@odata.count": 6,
"@PTC.AppliedContainerContext.LocalTimeZone": "America/St_Johns",
"value": [
-0.379386,
-1.15892,
-0.0983161,
0.379386,
-0.0766029,
0.740562
]
}
Get request:
GET /Visualization/Representations(<oid>)/AdditionalFiles?$count=true
This example shows the $count query option for the Complex types collection. The response is:
{
"@odata.context": https://<Windchill>/Windchill/servlet/odata/v3/Visualization/$metadata#Representations/AdditionalFiles,
"@odata.count": 2,
"@PTC.AppliedContainerContext.LocalTimeZone": "America/St_Johns",
"value": [
{
"URL": https://<Windchill>/Windchill/servlet/WindchillAuthGW/com.ptc.windchill.enterprise.wvs.saveWVSObject.utils.SaveWVSObjectHelper/saveWVSObject/...,
"Label": "golf_cart_de.xml",
"FileSize": 108461.0,
"MimeType": "text/xml",
"Format": "XML",
"ID": "OR:wt.content.ApplicationData:127656",
"FileName": "golf_cart_de.xml",
"LastModified": "2023-12-08T01:39:45-03:30",
"CreatedOn": "2023-12-08T01:39:45-03:30",
"Description": null,
"Comments": null
},
{
"URL": https://<Windchill>/Windchill/servlet/WindchillAuthGW/com.ptc.windchill.enterprise.wvs.saveWVSObject.utils.SaveWVSObjectHelper/saveWVSObject/...,
"Label": "golf_cart_es.xml",
"FileSize": 108981.0,
"MimeType": "text/xml",
"Format": "XML",
"ID": "OR:wt.content.ApplicationData:127737",
"FileName": "golf_cart_es.xml",
"LastModified": "2023-12-08T01:39:46-03:30",
"CreatedOn": "2023-12-08T01:39:46-03:30",
"Description": null,
"Comments": null
}
]
}
Get request:
GET /Visualization/Representations(<oid>)/BoundingBox/$count
This example shows that the /$count can be appended to the resource path to obtain the number of items for the structural properties of the Primitives type collection. The response is: 6
Get request:
GET /Visualization/Representations(<oid>)/AdditionalFiles/$count
This example shows that the /$count can be appended to the resource path to obtain the number of items for the structural properties of the Complex types collection. The response is: 2
Get request:
GET /ProdMgmt/GetWindchillMetaInfo()?$count=true
This example shows the $count query option for actions and functions. The response is:
{
"@odata.context": https://<Windchill>/Windchill/servlet/odata/v4/PTC/$metadata#Collection(PTC.EntityMetaInfo),
"@odata.count": 41,
"@PTC.AppliedContainerContext.LocalTimeZone": "America/St_Johns",
"value": [
{
"EntityType": "PTC.ProdMgmt.AXLEntry"
},
{
"EntityType": "PTC.ProdMgmt.PartAlternateLink"
},
{
"EntityType": "PTC.ProdMgmt.ManufacturerPart"
},
{
"EntityType": "PTC.ProdMgmt.VendorReplacementPart"
},
{
"EntityType": "PTC.ProdMgmt.WADMDesignSolution"
},
....
],
"@odata.nextLink": http://<Windchill>/Windchill/servlet/odata/v6/ProdMgmt/GetWindchillMetaInfo()?$select=EntityType&$count=true&$skiptoken=25
}