Process HTTP Requests
Hi, I need a service in Thingworx for receiving Http GET/Post requests and process it. How could I achieve this.
Hi, I need a service in Thingworx for receiving Http GET/Post requests and process it. How could I achieve this.
Hi Shankar Bandaru,
tl;dr
Every characteristic of Entity in Thingworx (Service, Property etc.) can be reached using REST calls. So if you'd like to create a service that receives a HTTP call you need to create a normal service. Beware: you can reach the services only using requests of type POST!
The input parameters of the service conforms to the body parameter of the request. So if your service have two parameters: name (STRING) and age (NUMBER), the body of your request should looks like below:
{
"name": "MyName",
"age": 1
}
The request should have ApplicationKey with permissions to invoke your service (better choice) or Userid and Password (worse choice).
Additionally, you can use headers: Content-Type: application/json and Accept: application/json.
The endpoind you should reach should follow the pattern:
http://<host>:<port>/Thingworx/<EntityType>/<EntityName>/Services/<ServiceName>
e.g.
http://localhost:8080/Thingworx/Things/MyThing/Services/MyService
If you use headers mentioned above and your service returns anything, it would be in the format of JSON (can set this baseType also on the service, if necessary).
Hope it helps. For more info, you should reach to the official REST API guides.
Regards,
J.
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.