Thanks a lot for your reply!
I’ve been trying to set up the API for V3 now. The devices do show up in my end-devices panel only the app-key is missing and when I try to connect them it’s being registered as an ABP device.
I used the method recommended by descartes before to have a sneak peak at how the web console registers the devices.
When I’m trying to do a sample post with made up figures (hence they are not hidden) im getting the following error responses:
Printing content of response1: b'{"ids":{"device_id":"test-for-app-key","application_ids":{"application_id":"cttwatermeter"},"dev_eui":"1133113311552216","join_eui":"8866554433221198"},"created_at":"2021-04-29T08:53:27.319Z","updated_at":"2021-04-29T08:53:27.319Z","name":"rikappkeytester","version_ids":{},"network_server_address":"eu1.cloud.thethings.network","application_server_address":"eu1.cloud.thethings.network","join_server_address":"eu1.cloud.thethings.network"}'
web_1 | Printing content of response2: b'{"code":3,"message":"error:pkg/networkserver:field_value (invalid value of field `supports_join`)","details":[{"@type":"type.googleapis.com/ttn.lorawan.v3.ErrorDetails","namespace":"pkg/networkserver","name":"field_value","message_format":"invalid value of field `{field}`","attributes":{"field":"supports_join"},"correlation_id":"036fe97ce040468c8f5bba63a65195b1","code":3}]}'
web_1 | Printing content of response3: b'{"code":3,"message":"error:pkg/applicationserver/redis:read_only_field (read-only field `ids.join_eui`)","details":[{"@type":"type.googleapis.com/ttn.lorawan.v3.ErrorDetails","namespace":"pkg/applicationserver/redis","name":"read_only_field","message_format":"read-only field `{field}`","attributes":{"field":"ids.join_eui"},"correlation_id":"fa23ff4216e44e49964e1e9a6300e05c","code":3}]}'
web_1 | Printing content of response4: b'{"code":3,"message":"error:pkg/joinserver/redis:read_only_field (read-only field `ids.join_eui`)","details":[{"@type":"type.googleapis.com/ttn.lorawan.v3.ErrorDetails","namespace":"pkg/joinserver/redis","name":"read_only_field","message_format":"read-only field `{field}`","attributes":{"field":"ids.join_eui"},"correlation_id":"f7ed038f98544cec817a7beec760002b","code":3}]}'
I’m using the following JSON data to send to the server (which I “stole” from inspecting the browser while creating an end-device):
data1 = {"end_device": {
"ids": {"device_id": "test-for-app-key", "dev_eui": "1133113311552216", "join_eui": "8866554433221198"},
"join_server_address": "eu1.cloud.thethings.network", "network_server_address": "eu1.cloud.thethings.network",
"application_server_address": "eu1.cloud.thethings.network", "name": "rikappkeytester"}, "field_mask": {
"paths": ["join_server_address", "network_server_address", "application_server_address", "ids.dev_eui",
"ids.join_eui", "name"]}}
data2 = {"end_device": {"multicast": False, "supports_join": True, "lorawan_version": "MAC_V1_0_2",
"ids": {"device_id": "test-for-app-key", "dev_eui": "1133113311552216",
"join_eui": "8866554433221198"}, "mac_settings": {"supports_32_bit_f_cnt": True},
"supports_class_c": False, "supports_class_b": False,
"lorawan_phy_version": "PHY_V1_0_2_REV_B", "frequency_plan_id": "EU_863_870_TTN"},
"field_mask": {"paths": ["multicast", "supports_join", "lorawan_version", "ids.device_id", "ids.dev_eui",
"ids.join_eui", "mac_settings.supports_32_bit_f_cnt", "supports_class_c",
"supports_class_b", "lorawan_phy_version", "frequency_plan_id"]}}
data3 = {"end_device": {
"ids": {"device_id": "test-for-app-key", "dev_eui": "1133113311552216", "join_eui": "8866554433221198"}},
"field_mask": {"paths": ["ids.device_id", "ids.dev_eui", "ids.join_eui"]}}
data4 = {"end_device": {
"ids": {"device_id": "test-for-app-key", "dev_eui": "1133113311552216", "join_eui": "8866554433221198"},
"network_server_address": "eu1.cloud.thethings.network",
"application_server_address": "eu1.cloud.thethings.network", "network_server_kek_label": "",
"application_server_kek_label": "", "application_server_id": "", "net_id": None,
"root_keys": {"app_key": {"key": "7138710500000000713871051F500739"}}}, "field_mask": {
"paths": ["network_server_address", "application_server_address", "ids.device_id", "ids.dev_eui",
"ids.join_eui", "network_server_kek_label", "application_server_kek_label", "application_server_id",
"net_id", "root_keys.app_key.key"]}}
url1 = 'https://eu1.cloud.thethings.network/api/v3/applications/cttwatermeter/devices'
url2 = 'https://eu1.cloud.thethings.network/api/v3/ns/applications/cttwatermeter/devices/tester2'
url3 = 'https://eu1.cloud.thethings.network/api/v3/as/applications/cttwatermeter/devices/tester2'
url4 = 'https://eu1.cloud.thethings.network/api/v3/js/applications/cttwatermeter/devices/tester2'
headers = {
"Authorization": "Bearer NNSXS.xxxx",
'Content-Type': 'application/json'}
response1 = requests.post(url1, data=json.dumps(data1), headers=headers)
print(f'Printing content of response1: {response1.content}')
response2 = requests.put(url2, data=json.dumps(data2), headers=headers)
print(f'Printing content of response2: {response2.content}')
response3 = requests.put(url3, data=json.dumps(data3), headers=headers)
print(f'Printing content of response3: {response3.content}')
response4 = requests.put(url4, data=json.dumps(data4), headers=headers)
print(f'Printing content of response4: {response4.content}')
what am I doing wrong? I have the feeling something in these field_masks is going wrong but I’m not sure where to correct it and how. If I remove the field masks I dont get an error but then my device is registered without the app key