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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Thingworx custom HTTP integration connector code example

Siddharth_Jhs
14-Alexandrite

Thingworx custom HTTP integration connector code example

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

 

 

 

ACCEPTED SOLUTION

Accepted Solutions

Hi @Siddharth_Jhs 

 

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

View solution in original post

5 REPLIES 5

Hi @Siddharth_Jhs 

 

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.

Siddharth_Jhs
14-Alexandrite
(To:Velkumar)

Hi @Velkumar@VladimirRosu 

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

 

 

 

Hi @Siddharth_Jhs 

 

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"
                    }
                }
            }
        }
    }
  }

 

Velkumar_0-1682787546587.png

 

Step 2: Update JSON value in Connector Property SwaggerJSON

Step 3: Execute GetEndPointList to get endpoints

 

/ VR

 

Siddharth_Jhs
14-Alexandrite
(To:Velkumar)

Thanks @Velkumar  It is working for me now.

 

Announcements


Top Tags