Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi Team,
I am new to REST API integration with Thingworx. I was exploring Integration connector topic in which it mentions to create custom HTTP integration connector. I was wondering if I can use this HTTP connector to integrate any REST api which is available as open source for testing (for eg any weather api ) ?
Also, can I get any example to create HTTP Integration connector. Thanks in advance.
Kindly assist.
Regards,
Sid
Solved! Go to Solution.
Check this link for Custom HTTP Connector creation - Creating a Custom Integration Connector (ptc.com)
Yes, you can integrate any REST API using Thingworx HTTP Connector. But you have to create a Swagger structure for the API endpoint list. You can refer to this link for Swagger Structure - Basic Structure (swagger.io) & OpenAPI Specification - Version 2.0 | Swagger (Thingworx supports JSON structure )
Alternatively, you can use ContentLoader functions in Thingworx to consume REST API - ContentLoader (ThingWorx Platform API 9.3.0) (ptc.com)
This site consists of some dummy API - Reqres - A hosted REST-API ready to respond to your AJAX requests You can play with it
/VR
Check this link for Custom HTTP Connector creation - Creating a Custom Integration Connector (ptc.com)
Yes, you can integrate any REST API using Thingworx HTTP Connector. But you have to create a Swagger structure for the API endpoint list. You can refer to this link for Swagger Structure - Basic Structure (swagger.io) & OpenAPI Specification - Version 2.0 | Swagger (Thingworx supports JSON structure )
Alternatively, you can use ContentLoader functions in Thingworx to consume REST API - ContentLoader (ThingWorx Platform API 9.3.0) (ptc.com)
This site consists of some dummy API - Reqres - A hosted REST-API ready to respond to your AJAX requests You can play with it
/VR
By far the easiest path I would suggest is using the ContentLoader, as @Velkumar suggested - if your application scale allows this.
Thank you for your response. I am able to use ContentLoader Functions to consume REST API's as Javascript code which you provided in example.
However, Please help me how I can consume same Swagger API using Integration Connector.
I have created Swagger connector and then in Configuration updated base url.
Sharing you ss of Integration connector I have created.
Still I am not able to get any endpoints loaded. Kindly Help.
Thanks,
Sid
As I told you in my previous post you have to create swagger JSON manually to get the endpoint list.
Step 1: Create Swagger JSON. You can use VS Code Plugin - OpenAPI (Swagger) Editor - Visual Studio Marketplace to create JSON. Note: Thingworx supports OpenAPI v2.0 only
Swagger JSON should look something like this
Below JSON consists of endpoint - https://reqres.in/api/users?page=2
{
"swagger":"2.0",
"info": {
"title":"Test API",
"version":"1.0"
},
"host": "reqres.in",
"basePath": "/api",
"schemes": ["https"],
"paths": {
"/users": {
"get": {
"description": "",
"parameters": [
{
"name": "page",
"in": "query",
"required": true,
"type": "string",
"description": ""
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
Step 2: Update JSON value in Connector Property SwaggerJSON
Step 3: Execute GetEndPointList to get endpoints
/ VR