thingsboard_api_tools icon indicating copy to clipboard operation
thingsboard_api_tools copied to clipboard

can you add relation api ?

Open xcloudlive opened this issue 4 years ago • 1 comments

it is a great job for accessing thingsboard, i really appreciated you. Now i need init many asset and device by api,but i found there is no relation in your code. can you add relation api ? Thanks!

xcloudlive avatar Apr 17 '20 05:04 xcloudlive

Hey, hope it is not late, but relation can be added like this:

relations = {"from": {"id": from_entity_id, "entityType": from_entity_type}, "type": "Contains", "to": {"entityType": to_entity_type, "id": to_entity_id}}

relations_r = requests.post('http://127.0.0.1:8080/api/relation', json=relations, headers=headers)

headers should be the usual part as is in the code.

fjpa121197 avatar Jun 08 '20 16:06 fjpa121197