Skip to main content
5-Regular Member
September 17, 2016
Solved

Consume REST API services in Thingworx

  • September 17, 2016
  • 9 replies
  • 11086 views

Hi Team,

I am new to Thingworx and still learning basic stuff. Can anyone help me with how to consume third party web services(REST API) in Thingworx?

May be this topic is already discussed but i am not able to find it. . Do i need to do it using extension or EDGE will help me achieve this.

My requirement is: I have to call http://......axeda.com/services/v1/rest/ services in Thingworx to read response and display it in Mashup.

Please share any sample or tutorials or guides to do it. Anything related to above topic will be very helpful.

Thanks everyone in advance.

Ravi

Best answer by VladimirRosu_116627

Hi Ravi,

The ability to call webservices is one of the most used features that we have Out-Of-The-Box in ThingWorx.

Presuming you're already familiar with the platform, you'll just need to use the Snippets from the section "ContentLoaderFunctions".

They offer wrappers for all the HTTP verbs: POST, PUT, GET, DELETE.

If you hover the mouse over each snippet you'll see the documentation in a popup on the screen.

Best regards,

Vladi

9 replies

19-Tanzanite
September 17, 2016

Hi Ravi,

The ability to call webservices is one of the most used features that we have Out-Of-The-Box in ThingWorx.

Presuming you're already familiar with the platform, you'll just need to use the Snippets from the section "ContentLoaderFunctions".

They offer wrappers for all the HTTP verbs: POST, PUT, GET, DELETE.

If you hover the mouse over each snippet you'll see the documentation in a popup on the screen.

Best regards,

Vladi

rsingh-85-Regular MemberAuthor
5-Regular Member
September 18, 2016

Thanks Vladi for your response.

I am new to this framework and going to take training from PTC next week but i have some idea and was able to find ContentLoaderFunctions in Things->Services->Snippet.

Still lot to explore. Can you please recommend some samples on ContentLoaderFunctions. I have PTC(PrecisionLMS account).

Thanks

Ravi

19-Tanzanite
September 18, 2016

Hi Ravi,

So, the best way to do this would be to first take the training, then go to explore the snippets, as lots of things will make more sense in this way.

Regarding an usage example, it's really simple:

1. Put the url that you want to call in the URL parameter of the GetText function (as an example, of course you can run any of the other functions)

2. Run the service where you put this snippet.

3. If you want to see the result of this service, set the output as STRING as well.

Again, I think it makes more sense to go through the training first, then use the snippets.

Hope it helps

Vladi

1-Visitor
March 21, 2017

Hi Vladimir Rosu,

I  need to pass multiple body parameters say 5 parameters in body section. Not sure where to add those details in the GetText of ContenLoader fucntions?

var params = {

  proxyScheme: undefined /* STRING */,

  headers: undefined /* JSON */,

  ignoreSSLErrors: undefined /* BOOLEAN */,

  useNTLM: undefined /* BOOLEAN */,

  workstation: undefined /* STRING */,

  useProxy: undefined /* BOOLEAN */,

  withCookies: undefined /* BOOLEAN */,

  proxyHost: undefined /* STRING */,

  url: undefined /* STRING */,

  timeout: undefined /* NUMBER */,

  proxyPort: undefined /* INTEGER */,

  password: undefined /* STRING */,

  domain: undefined /* STRING */,

  username: undefined /* STRING */

};

// result: STRING

var result = Resources["ContentLoaderFunctions"].GetText(params);

Given above is the GetText service code. Please let me know where to add the five parameters of the body section which usually we pass in a REST API call based on the need.