我的目标是将属性发送到每个设备。
我可以通过/api/tenant/devices
获取设备。但这不包括设备 token 。
{
"data": [
{
"id": {
"entityType": "DEVICE",
"id": "66c2f980-4568-11e9-a10d-9be803b14c20"
},
"createdTime": 1552465031448,
"additionalInfo": null,
"tenantId": {
"entityType": "TENANT",
"id": "3a0833a0-455a-11e9-8dde-a383dc31d4aa"
},
"customerId": {
"entityType": "CUSTOMER",
"id": "13814000-1dd2-11b2-8080-808080808080"
},
"name": "USB 23393",
"type": "usb"
},
我应该使用的 API 是 /api/v1/[device toekn]/attributes
我怎样才能做到这一点?
最佳答案
我可以从Thingsboard的swagger api中找到。
这是我的最终代码。希望这对某人来说。
let url = '/api/device/' + device.id.id + '/credentials';
axios.defaults.headers.common['X-Authorization'] =
'Bearer ' + localStorage.getItem('accessToken');
axios.get(url)
.then(response => {
console.log(response.data);
let credentialsId = response.data.credentialsId;
return credentialsId;
})
.then(credentialsId => {
url = '/api/v1/' + credentialsId + '/attributes';
console.log(url);
关于thingsboard - 如何以编程方式从 ThingsBoard 获取设备 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55591169/