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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Custom code to get data using OData API

Riz-4165786
12-Amethyst

Custom code to get data using OData API

Hello All,

I have created a integration connector with oData connector as base template and able to connect windchill.
Using new composer I am able to map the existing endpoints. For example Workflow/WorkItems. I am able to get few of the APIs available in WRS but not able to see all the exact API Endpoints for example I can see endpoints for GET /WorkItems but I can't see endpoint for GET /WorkItems('{WorkItemId}')/Subject
Also, I didn't find any useful document/code which tells how to invoke GET /WorkItems('{WorkItemId}')/Subject endPoint. Where we can pass WorkItemId as an input parameter and get the details. In case of Legacy Rest I was using below code to get the data. Not sure how to achieve the same using OData.

var jsonResult = me.processJSONRequest(params);

Any idea, how to achieve above requirement using OData REST API.

ACCEPTED SOLUTION

Accepted Solutions

Hi,

Issue discussed through case :

 

In ODATA connector, create a Service and enter information below :

  • Endpoint (required) : getWorkItemInWorkItemsByID (/Workflow/Workitems({'ID'}) GET)
  • $expand : Subject

 

schauvelin_0-1613139286975.png

 

Solution reported in article : https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS338990 

If solution provided is ok for you can you mark this post as "Accepted Solution"

 

Kind regards. 

View solution in original post

7 REPLIES 7

Since you are asking about integration between ThingWorx and Windchill first of all verify that you have latest supported versions of WRS for Windchill, Windchill Patches and Integration Runtime installed.

 

Next verify the API you want to use in ThingWorx is available in Windchill and test it there first. If you have done this and still not working can you let me know what version of Windchill, WRS, Integration Runtime and ThingWorx you are using?

Thank you for your reply on this!

I believe we have latest supported version of WRS for Windchill and integration-runtime. 

I verified the API that I am looking for is available in Windchill, I have ran it in Windchill and it returns the data well. I have attached all the required screenshots. I hope the screen shots help. I would like to know how can I get data for /WorkItems/('{workflowid}')/subject REST call from my Thingworx service. All I could see are few out of the box services available for /WorkflowItems in Odata Connector and not all as is seen in Windchill. It will be really great if you can let me know how I can include and call these services from Thingworx.

Please let me know if you need any further detail.

 

 

Forgot attachment in the previous reply so attaching it now

ThingWorx doesn't define what APIs are available they are discovered by ThingWorx so if some OData API is not available in ThingWorx but it is available as REST API that means Windchill doesn't expose this API over OData protocol.

 

As for how to call these services from ThingWorx, follow this chapter Creating a New API Map for the Service to create service in ThingWorx and map it to OData API. Then you can invoke such service as any other service.

Is there a way in Windchill where windchill can expose all the rest services over OData protocol?

If certain endpoint like GET /WorkItems('{WorkItemId}') is not available then I assume there is possibly something wrong with thee Windchill deployment. You may want to check with Windchill support to verify your Windchill installation.

Hi,

Issue discussed through case :

 

In ODATA connector, create a Service and enter information below :

  • Endpoint (required) : getWorkItemInWorkItemsByID (/Workflow/Workitems({'ID'}) GET)
  • $expand : Subject

 

schauvelin_0-1613139286975.png

 

Solution reported in article : https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS338990 

If solution provided is ok for you can you mark this post as "Accepted Solution"

 

Kind regards. 

Announcements


Top Tags