Skip to main content
1-Visitor
July 25, 2016
Question

How to build a service in order to get data (in the form of JSON) from a Web Service and bind it to the properties of a thing automatically.

  • July 25, 2016
  • 3 replies
  • 2146 views

Build a service which receives a response from a web service and the values which it gets in the response(JSON) are binded to the properties of a Thing.

3 replies

12-Amethyst
July 25, 2016

Can you provide more details on the usecase? There might be an alternate solution to achieve what is intended.

To answer the question directly - the service can set the property on the Thing directly.

If the service is written in the same thing -- me.myproperty=<value>

or Thing["myThing"].myproperty=<value>

5-Regular Member
July 25, 2016

Look for the service PostJSON which takes as its parameter an external web URL.It should be on the ContentLoaderFunctions Resource. The web interface you are requesting has to be RESTful, I believe.

Hope this helps!

Tori

1-Visitor
July 26, 2016

Hi Priyanshi,

You got the answers in the reverse order

First, as Tori said, look at ContentLoaderFunctions Resources, where you have plenty of services to call remote web services ( REST calls: POST, GET, DELETE,... , PostJSON/Text/XML, GetJSON/Text... ).

Then once received the result and parsed accordingly depending on your remote web service, you can use what Sajid said, set Thing current properties ( me.propertyName=value, or another thing Things["thingName"].propertyName = value; )

Best Regards,