Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hi everyone,
is there a way in thingworx to make a http post request with JSON or text content to an external service and receive a BLOB?
// result: JSON
var result = Resources["ContentLoaderFunctions"].PostJSON({
url: "http://xyz:8080/createFile",
content: {"filename":"test"}
});
Things["MyRepository"].SaveBinary({
path: "/",
content: result
});
The PostJSON method expects a JSON response but we would like to store the received binary in a file repository.
Is there a more generic way to make HTTP requests or do we have to create a extension for that.
Thanks
Solved! Go to Solution.
Hi eyeryone,
a look into the source code offers us that it's not possible with the out of the box services provided by Thingworx. We had to create an extension for that.
Best regards
Hi @JayT9000.
Without knowing more regarding your use case, it sounds like the information is being returned as JSON. Therefore, you would need to parse it for the desired information.
If we're failing to understand your request, please provide details of your use case and we'll take another shot at it.
Regards.
--Sharon
Hi Sharon,
Thanks for your reply. We have an external service which generates a binary file and we would like to store it in a file repository in thingworx. It seems that all http requests of the ContentLoaderFunctions resources expects the same output like the input.
e.g.
PostJSON -> send JSON --> expect JSON as result
PostBinary -> send BLOB --> expect BLOB as result
But in our case the service needs to receive JSON via post and sends a blob back.
Do you have any ideas?
Best regards
Jan
Hi @JayT9000.
We're still not clear on your use case. You indicated your external service is creating a binary file, but then state that the service needs to receive JSON. What is this external service that is generating the binary file? If you want it stored in the ThingWorx repository as JSON, you will either need to convert it before sending to ThingWorx or write a service in ThingWorx to handle the conversion. The snippets provided in ThingWorx may require some additional coding to function as needed.
Regards.
--Sharon
Hi eyeryone,
a look into the source code offers us that it's not possible with the out of the box services provided by Thingworx. We had to create an extension for that.
Best regards