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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Error in JSON String

vr-6
12-Amethyst

Error in JSON String

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]]

}

ACCEPTED SOLUTION

Accepted Solutions
jamesm1
12-Amethyst
(To:vr-6)

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

View solution in original post

2 REPLIES 2
jamesm1
12-Amethyst
(To:vr-6)

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

sharmon
13-Aquamarine
(To:jamesm1)

I verified James McCuen​ 's results with POSTMan. Here's my service:

2016-12-09 22_48_34-ThingWorx Composer - Firefox Developer Edition.png

Here's my POSTMan POST. Note - I'm using POSTMan environment variables. That's where the {{protocol}}, {{host}}, ... stuff comes from.

2016-12-09 22_45_18-Postman.png

Announcements


Top Tags