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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to make a REST request for retrieving data

GV_10573671
4-Participant

How to make a REST request for retrieving data

Hi friends!

 I have a question/doubt about IoT Gateway's REST Client:  

 

How can I make a GET request from REST Client in order to retrieve some data from an external API (e.g. Weather, web application, etc)?.

 

As you know, it only supports PUT & POST method and it's fine but what about if I want to connect to Google Maps, Open Trivia  or AccuWeather  and retrieve/handle some values??

GV_10573671_0-1675181868491.png

 

Even, I have a Google sheet's script deployed as web application listening external calls to log data in my sheet and I just need a simple GET request to achieve it but I can't find a way to do it from IoT Gateway module. My URL to get this is: 

"https://script.google.com/macros/s/ SCRIPT_ID/exec?temp1=1234&level=122&pressure=88"

 

What would be the procedure or module to achieve it?

 

Thanks in advance for your prompt reply and help,

 

Saludos!

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

I suggest reviewing the IoT Gateway User Manual, available here.

In short, the IoT Gateway is a plugin that is used in Kepware to publish tag values (through different methods, like REST or MQTT).

Any sort of custom coding is not its intended use-case (generally speaking).

ThingWorx on the other hand is an Industrial IoT Platform (description here), where you can build applications for a variety of use-cases.

The use-case you shared is something that ThingWorx would help you to do, as it contains something ContentLoader snippets that allow you to execute GET,POST,PUT and then use it in Javascript to your liking.

 

ThingWorx and Kepware are very different, though it is worth mentioning that Kepware can be integrated in ThingWorx out of the box, via a native integration capability (you can receive tag values in ThingWorx directly, can modify a Kepware configuration directly from TW).

View solution in original post

6 REPLIES 6

Hello @GV_10573671 

You may refer the following articles for the Rest API services:

 

https://www.ptc.com/en/support/article/cs329281

https://www.ptc.com/en/support/article/cs224211

 

Pls let me know if it works for you.

Regards

Bhawna

Thanks Bhawna! 

 

I will try using Thingworx.  I thought that using IoT Gateway was enough to do what I want.

 

But now I have a doubt:  when would I have to use IoT Gateway instead of Thingworx?

Is Thingworx the IoT Gateway's older bother ?  Is it more expensive? 

 

Have a great day!

Gavp

I suggest reviewing the IoT Gateway User Manual, available here.

In short, the IoT Gateway is a plugin that is used in Kepware to publish tag values (through different methods, like REST or MQTT).

Any sort of custom coding is not its intended use-case (generally speaking).

ThingWorx on the other hand is an Industrial IoT Platform (description here), where you can build applications for a variety of use-cases.

The use-case you shared is something that ThingWorx would help you to do, as it contains something ContentLoader snippets that allow you to execute GET,POST,PUT and then use it in Javascript to your liking.

 

ThingWorx and Kepware are very different, though it is worth mentioning that Kepware can be integrated in ThingWorx out of the box, via a native integration capability (you can receive tag values in ThingWorx directly, can modify a Kepware configuration directly from TW).

Thanks @VladimirRosu , I'm learning a bit more though to be honest, I know and have worked with KepServerEX since the 1990's when OPC was released and it made our lives simpler but I never used nor took at look at ThingWorx.

 

Even, I have almost 2 years using your  IoT Gateway via REST Server and has worked perfect but now I have a new need/idea to send data to Google Cloud from my devices directly and a simple GET request from  to IoT Gateway is the missing part I'm needing but as you know, the REST Client doesn't support this method.

 

Another question: Is  IoT Gateway able to work witn OAuth 2.0 authorization using a PUT method ? If so, where can I find a manual to get it?  This might be my plan B in order to work with Google Sheets API.

 

Thanks again for your  time and help.

 

Feliz día!

Gavp

 

 

 

 

Hi Gavp,

If you look in the first line of my last comment, I added a link to the IoT GW User Manual there. Everything related to the IoT GW, what it can do, etc, is in there.

The REST client is designed to send data directly via PUT/POST since these are the only HTTP verbs that modify the targeted resource.

GET on the other hand is used by design to get a resource representation, and while it is correct it can be used in a first step to get an OAUTH token, that worklow is not supported.

Thanks again!

 

Let me read a little more and test and I will let you know my results.

 

BTW, don't you have a demo/example where ThingWorx is able to write to a Google Sheet via GET or PUT?

 

Saludos!

 

 

Top Tags