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

Get multiple property values (single thing) using REST API

Visitor

Get multiple property values (single thing) using REST API

Hi,

 

I am trying to GET multiple property values of a single THING. I saw posts using POSTMAN, but I'm trying to use Python REST API. I have created 2 items and given them default values. In the below code, I am able to print a single value of the property "item1"  which is 20.0. How do I fetch all properties using a single REST API call?items.PNG

 

 

#https://academic.cloud.thingworx.com/Thingworx/Things/testmultiple_/Properties/item1

import json
import requests

url_parts = {'entity': 'Things',
'platform': 'Thingworx',
'Thing_Name':'testmultiple_,
'property': 'item1'}

headers = {'appKey': 'fdb763fc-e369-483b-baa5-8445bd8746ee',
'Accept': 'application/json'}

url_template = 'https://academic.cloud.thingworx.com/{platform}/{entity}/{Thing_Name}/Properties/{property}'
response = requests.get(url_template.format(**url_parts), headers=headers).json()
s = response["rows"][0]["item1"]
print(s)

 

Tags (2)
4 REPLIES 4

Re: Get multiple property values (single thing) using REST API

You called the wrong API.

 

There is a service called GetPropertyValues in most Things, if you use this API, you can get an infotable of the results, and you can print the values you want. (infotable in Python is probably a Matrix)

Re: Get multiple property values (single thing) using REST API

@zyuan1 Is there an example than you can refer me to? I am just starting to explore Thingworx.

Re: Get multiple property values (single thing) using REST API

I do not find the service listed in the section. Is it a custom function that we should write? 

getpropertyvalues.PNG

Re: Get multiple property values (single thing) using REST API

There is a guide to getting started with the REST API here:

https://developer.thingworx.com/resources/guides/rest-api-how-guide/things-rest-api-how