I found the following: https://www.thethingsnetwork.org/docs/applications/manager/api.html#setdevice
However, I have some questions.
The input, to the endpoint ( POST
/applications/{app_id}/devices
), is the following:
{
"altitude": 0,
"app_id": "some-app-id",
"attributes": {
"key": "",
"value": ""
},
"description": "Some description of the device",
"dev_id": "some-dev-id",
"latitude": 52.375,
"longitude": 4.887,
"lorawan_device": {
"activation_constraints": "local",
"app_eui": "0102030405060708",
"app_id": "some-app-id",
"app_key": "01020304050607080102030405060708",
"app_s_key": "01020304050607080102030405060708",
"dev_addr": "01020304",
"dev_eui": "0102030405060708",
"dev_id": "some-dev-id",
"disable_f_cnt_check": false,
"f_cnt_down": 0,
"f_cnt_up": 0,
"last_seen": 0,
"nwk_s_key": "01020304050607080102030405060708",
"uses32_bit_f_cnt": true
}
}
It says “all fields must be supplied”. What do I when I use OTAA, do I leave the app_s_key, dev_addr, nwk_s_key etc fields emtpy?
"app_s_key": "",
"nwk_s_key": "",
"dev_addr": "",
My script would look something like this:
import requests
access_key = "secret-xxxxxxxxx.."
key= "Key {}".format(access_key)
endpoint = "http://eu.thethings.network:8084/applications/<app_id>/devices/"
params = dict linked above
requests.post(endpoint,headers={"Authorization": key}, params = params)
However, im getting the following error msg: Invalid Device: DevID not valid: can not be empty
Any help?
Thanks.