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

format of JSON for PUT method of geo type property

Newbie

format of JSON for PUT method of geo type property

Hi, I want to post lat long and height to loc property (field type geo). I am trying this


URL :-localhost:8080/Thingworx/Things/liveVehicle/Properties/loc


HEADERS :-


rest_thing_api:e3c27605-2c66-40d6-b914-4a6bf57c1f33

Userid:Administrator

Password:admin

Content-Type:application/json

JSON

{

      "lon": "104.211",

      "lat": "10220.030",

      "height": "0"

    }


Please suggest correct format of jSON?

Tags (1)
20 REPLIES 20

Re: format of JSON for PUT method of geo type property

Hello Prabhat,

I can show you one trick. In the Composer go to your Thing with Location property. You can set the value manually:

1.PNG

In meanwhile go to the browser Developer Tools (F12 in Chrome) and then to the Network Tab.
Come back to the Composer and click Done to set dummy value.

2.PNG

Every change like this is also a REST PUT request. So you can take a look on the Headers and Request Payload to see how it should look like.

I hope it helps.

Regards,

Adam

Re: format of JSON for PUT method of geo type property

It's showing JSON Content for loc Was Not ValidProperties

Re: format of JSON for PUT method of geo type property

Its showing error :- JSON Content for loc Was Not ValidProperties

Re: format of JSON for PUT method of geo type property

My bad, I forgot to tell you that property names must be also in quotes just like this:

{

    "location": {

        "latitude": 50,

        "longitude": 50,

        "elevation": 50

    }

}

Remember that JSON format require property names in quotes.

Regards,

Adam

Re: format of JSON for PUT method of geo type property

Thanks, It worked out.

So the correct format of JSON will be ( for other buddies who might face same same problem)

{ "loc": {"latitude": "0.1111", "longitude": "0.22222", "elevation": "033333", "units": "WGS84"}}

Re: format of JSON for PUT method of geo type property

Hi. status Code is saying 200.

But value is not reflecting in property.

Re: format of JSON for PUT method of geo type property

I tested your values and I am receiving 406. Probably because "elevation": "033333" ​ is not acceptable.

This is my JSON:

{

    "location": {

        "latitude": 0.1111,

        "longitude": 0.2222,

        "elevation": 0.3333,

        "units": "WGS84"

    }

}

Remember also to setup proper REST Headers:

appKey/Authorization

Accept -> application/json

ContentType -> application/json.

You also check for ThingWorx logs to see if there is more information there.

Regards,

Adam

Re: format of JSON for PUT method of geo type property

One more thing is that if you will save your thing, after setting up some values you will lost it.

To keep it 'forever' you need to tag you property as Persistent.

Regards,

Adam

Re: format of JSON for PUT method of geo type property

Hi Adam,

Could you please show e the entire code of format, because am also posting values in the form of json