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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Use Thingworx Service as REST API

Jamal8548
10-Marble

Use Thingworx Service as REST API

I want to use the thingworx service and send the data to Power Automate but now limitation is i am unable to make GET request from Thingworx platform. Is it possible that thingworx Api can work as Get API so that i can get the data in Power Automate. Can anyone please spread light on this topic. I would like to get the data with GET HTTP method and NOT POST METHOD.

1 ACCEPTED SOLUTION

Accepted Solutions
nmutter
14-Alexandrite
(To:Jamal8548)

From ThingWorx you want to send a GET/POST request to Power Automate?

You can use ContentLoaderFunctions:

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

- https://community.ptc.com/t5/IoT-Tips/ContentLoaderFunctions-in-ThingWorx/ta-p/820230

 

Or do you want send data from Power Automate to ThingWorx?

View solution in original post

11 REPLIES 11
nmutter
14-Alexandrite
(To:Jamal8548)

From ThingWorx you want to send a GET/POST request to Power Automate?

You can use ContentLoaderFunctions:

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

- https://community.ptc.com/t5/IoT-Tips/ContentLoaderFunctions-in-ThingWorx/ta-p/820230

 

Or do you want send data from Power Automate to ThingWorx?

i would like to send the data from Thingworx as a REST API but not with post request. I want to send the data with GetHTTP Request. do you have any idea about it? Can you please let me know?

nmutter
14-Alexandrite
(To:Jamal8548)

ContentLoaderFunctions has these GET requests

GetJSON, GetText, GetXML

 

Sending data via get you have to do by adding the data via query string (?data=myData). Like http://<host>/?data=myData

The format of how you send it will depend on the target system - how it expects the data.

https://jama44444.malik.jamal-world.com:2019/Thingworx/Things/Quality.Main.Controller/Services/LiveDataAPI?Linename=02

this is my thingworx link which returns the json data when i hit the requestiwth PostJSON method from ContentLoaderFunctions then it works but i am unable to get the data with GetJSON. can you please tell me what i am doing wrong. It is returning my headers again. i have attached a screen shot also


 

tr.png

I think i need to clear you my query. The query is that i want to send the data from thingworx and another department from my team want to get the data via REST API but that department ask me that they can only access the data via GET REQUEST only. But as far as i know thingworx can only offer POST http method for the REST API structure. do you have any idea that how can i achieve this task? how can i give user the link from thingworx service and he can make a get request and get the data. 

with these ContentLoaderFunctions. i am not sure that this task would be possible because even though after write the function with GET request i still need that service link and that thingworx service can only be hit with POST Request. As you can see you can only execute service with post http.

 

rest.png

nmutter
14-Alexandrite
(To:Jamal8548)

So someone wants to call ThingWorx? Not the other way around (ThingWorx calling some other system)?

 

There is the possibility (which is deprecated) to make a GET request but specify a parameter in the url 'method=post' to support your useCase:

- You need to allow "Allow Request Method " in PlatformSubsystem (see https://support.ptc.com/help/thingworx/platform/r9/en/index.html#page/ThingWorx/Help/Composer/System/Subsystems/PlatformSubsystem.html )

So with that enabled they can do a request.

 

https://www.ptc.com/en/support/article/CS224211 has an example 

 

Let me know if that helps!

I think there is no way to execute the service of thingworx with GET request as you can see in the screenshot below. I just want to send the datatable entries to the other platform but now i have an idea that i will set the property of thing as an infotable and fill the data in it and then with get request i am able to fetch it. or do you have some other solution for me? I want entries to go into another platform. for now i am thinking to fill the data into the VALUE of the PROPERTY programmatically and then the people can get our data with get request.

 

fina.png

nmutter
14-Alexandrite
(To:Jamal8548)

I am still unclear what you want to do.

But from the article you can execute a thingworx service with a GET call if you send it with the method=POST parameter. It is not so clear maybe from the table but the first column is bascially the request type which it should be, but with the 'workaround' in the column next to it you can achieve what you want:

nmutter_0-1708521326387.png

 

I want to execute the thingworx service with GET Request which is not possible at all!! I dont want to use POST request method because my other team where they want our thingworx data that platform do not use this post request. i hope u understand me now.

nmutter
14-Alexandrite
(To:Jamal8548)

Ok. But this is what we are talking about. You can do it like that:

GET https://<HOST>/Thingworx/Things/Quality.Main.Controller/Services/LiveDataAPI?method=POST

When in the PlatformSubsystem you did enable the "Allow Request Method"

See

nmutter_0-1708522887519.png

 

But as stated, this is a deprecated feature. If you have a better way for your issue it may be more future proof.

 

Thank you for your help. Its working now.  Great!

Top Tags