Hi,
Below is my JSON data format from my IoT device. We can't change below JSON string format. When I pass this String to TWX it shows error in JSON String format. Help me to fix this. Thanks in advance.
{
"PE":128,
"UID":"WISE-4051_00D0C9CC0077",
"MAC":"00-D0-C9-CC-00-77",
"TIM":"1480322199",
"Record":[[0, 1, 1, 0],[1, 1,32, 0],[1, 1,33, 17]]
}
Solved! Go to Solution.
Hey Velkumar,
I was just able to consume this json message correctly in thingworx. Can you test the following steps and tell me what your results are?
- Create a thing in Thingworx called JsonTestingThing based on a GenericThing
- Create a service with an input of type JSON called json
- Set the output type to JSON
- the code should be:
result = json;
Now, execute this service via cURL or postman:
curl -X POST -H "apiKey: [API KEY HERE]" -H "Content-Type: application/json" -H "Accept: application/json" -H "x-thingworx-session: true" -d '{
"PE":128,
"UID":"WISE-4051_00D0C9CC0077",
"MAC":"00-D0-C9-CC-00-77",
"TIM":"1480322199",
"Record":[[0, 1, 1, 0],[1, 1,32, 0],[1, 1,33, 17]]
}' "[THINGWORX URI HERE]/Thingworx/Things/JsonTestingThing/Services/test?postParameter=json"
Thanks
-James
Hey Velkumar,
I was just able to consume this json message correctly in thingworx. Can you test the following steps and tell me what your results are?
- Create a thing in Thingworx called JsonTestingThing based on a GenericThing
- Create a service with an input of type JSON called json
- Set the output type to JSON
- the code should be:
result = json;
Now, execute this service via cURL or postman:
curl -X POST -H "apiKey: [API KEY HERE]" -H "Content-Type: application/json" -H "Accept: application/json" -H "x-thingworx-session: true" -d '{
"PE":128,
"UID":"WISE-4051_00D0C9CC0077",
"MAC":"00-D0-C9-CC-00-77",
"TIM":"1480322199",
"Record":[[0, 1, 1, 0],[1, 1,32, 0],[1, 1,33, 17]]
}' "[THINGWORX URI HERE]/Thingworx/Things/JsonTestingThing/Services/test?postParameter=json"
Thanks
-James
I verified James McCuen 's results with POSTMan. Here's my service:
Here's my POSTMan POST. Note - I'm using POSTMan environment variables. That's where the {{protocol}}, {{host}}, ... stuff comes from.