2 Replies Latest reply on Dec 9, 2016 10:49 PM by sharmon RSS
    vr-2 Explorer

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

    }

      • Re: Error in JSON String
        jamesm Creator

        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