Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello
I have to connect a service provider API to a Thingworx service using REST POST ( with some parameters into the header and a json structure into the body)
In order to understand and debug first, I'm using POSTMAN to reproduce the API from provider.
I have created the Thingworx service and I am well accessing to it from postman using an appKey as header parameter.
the result of the service ("OK") is well returned to postman
I have followed some forum topics which are describing this, but I'm not able to access to the other parameters and to the json structure into the javascript code of the Thingworx service.
Should I have to define one input parameter for each header parameter with the same name ? what should be the name of the json structure into the body ?
each time I try to display an input parameter into the logger I get "undefined"
thanks for help
Pascal
UPDATE
I managed to get the parameters in the header (problem with Postman ?) but I'm still looking how to retrieve a json structure into the body
Thnaks
Hey Pascal,
If I understand correctly, you are trying to post a JSON body parameter to a Thingworx service via REST.
The correct way to do this is using the postParameter url parameter when invoking the service; here is an example:
Create a service with the parameter name json
add the URL Parameter postParameter where the value is the name of the json parameter you wish to pass:
Here is a cURL example:
curl -X POST \
'http://localhost/Thingworx/Things/Main.FileRepository/Services/TestService?postParameter=json' \
-H 'accept: application/json' \
-H 'appkey: efdb7b81-461c-4d04-bffb-a4e0fd2cd85c' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: c03973a6-a9ff-9786-1f88-47e757612c75' \
-d '{"test": 10}
'
thanks it is clear