Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
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?
#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)
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)
@zyuan1 Is there an example than you can refer me to? I am just starting to explore Thingworx.
I do not find the service listed in the section. Is it a custom function that we should write?
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