Skip to main content
1-Visitor
August 31, 2017
Question

format of JSON for PUT method of geo type property

  • August 31, 2017
  • 20 replies
  • 7831 views

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?

20 replies

15-Moonstone
August 31, 2017

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

pmishra-41-VisitorAuthor
1-Visitor
August 31, 2017

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

pmishra-41-VisitorAuthor
1-Visitor
August 31, 2017

It's showing JSON Content for loc Was Not ValidProperties

15-Moonstone
August 31, 2017

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

pmishra-41-VisitorAuthor
1-Visitor
August 31, 2017

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"}}