Problem with V3 HTTP api

Hi everyone,

I’m working on V3 API now, which goes remarkably well.
Still have one issue though.

My goal is to add devices to my account with the HTTP api.
I use the API key which I generate for each application, a method which is OK for me>

I can add a device using the EndDeviceRegistry.Create methods, this is going well and I see the device created in my account.

Unfortunately I cannot run sucessfulle the NsEndDeviceRegistry.set

The API keeps telling I have an error in my field mask area.
I think I am supposed to enter in the field mask which items I want to update ( I want to update network session keys obviously NwkSkey, we use ABP)

Can someone tell me how to enter the “field_mask” : { } when I do a POST call to the api/v3/ns/applications/my_app/devices

I cannot figure it out. I get the idea of the field masks when I do a GET to the API, but not when I do a POST tot the API.

This is my javascript body which I send ( Using postmaster )
I know I must implement ‘end_device’ AND 'field_mask" but I don’t know how to implement the latter.

Can someone help me a bit further ?? Thank you in advance !!

Arian.

POST to

https://eu1.cloud.thethings.network/api/v3/ns/applications/myapp/devices

Body:

{

“end_device”: {

"ids": {

    "device_id": "7070707070707070",

    "application_ids": {

        "application_id": "myapp"

    },

    "dev_eui": "7070707070707070"
    },

    "name": "device666" ,    

    "description" : "device no 666",

    "network_server_address" :  "eu1.cloud.thethings.network",

    "application_server_address" :  "eu1.cloud.thethings.network",

  "lorawan_version": "1.0.3",

"lorawan_phy_version": "1.0.3-a",

"frequency_plan_id": "EU_863_870",

"supports_join" : false,

        "session": {

        "dev_addr": "26ABBBAA",

        "keys": {

            "f_nwk_s_int_key": {

                "key": "56B53196B3571871C348A7A1BC9E0362"

            },

            "s_nwk_s_int_key": {

                "key": "56B53196B3571871C348A7A1BC9E0362"

            },

            "nwk_s_enc_key": {

                "key": "56B53196B3571871C348A7A1BC9E0362"

            },

                        "app_s_key": {

            "key": "075EAC7B7AFC7558339A3EBD294DCDE9"

        }

        }

    }

},

“field_mask” : { “field”: “frequency_plan_id”} → Help ??? :smile:

}

My recommendation for anyone working with the HTTP API would be to take inspiration from the Console, as it uses the exact same HTTP APIs that you’re trying to use.

Open the Console in your favorite browser. Then open the Developer Tools of your web browser and select the “Network” tab of the Developer Tools. Now execute the actions you’re trying to implement. The “Network” tab should capture the requests the Console makes, and you can see exactly what your application would need to do.

Screen Shot 2021-02-05 at 11.09.07

(don’t mind that 409 error, that’s a known bug in the Console that’s getting fixed)

3 Likes

This is the approach I took found it very quick way to get started

Hylke, thank you very much.

This is indeed the quick way to start. Now I have my commands available in Postman.
It did help me very much !

Hylke, dank je wel zover !

Groets Arian