How to switch Relays via http

Unfortunately, I can only find examples of HTTP downlinks for TTNv2, not for TTNv3.
The aim is to control the two relays of a Dragino LT-22222-L I/O controller via http.
These are the 4 possible states:

relay1 Off relay2 Off AwAA “03 00 00” F-Port 2
relay1 On relay2 On AwEB “03 01 01” F-Port 2
relay1 On relay2 Off AwEA “03 01 00” F-Port 2
relay1 Off relay2 On AwAB “03 00 01” F-Port 2

This is how I’ve tried it so far:
curl --location \ --header ‘Authorization: Bearer NNXXX.My_Token_with_enable_Write_downlink_application_traffic’ \ --header ‘Content-Type: application/json’ \ --header ‘User-Agent: my-integration/my-integration-version’ \ --request POST \ --data ‘{“downlinks”:[{ “frm_payload”:“AwEB”, “f_port”:2 }] }’ \ ‘https://thethings.example.com/api/v3/as/applications/my-application-id/devices/eui-my_end-device_id/down/push

Nothing appears on the console.
Maybe something has to be used for User-Agent: my-integration/my-integration-version?
Would be very grateful for any example or hint.

A forum search showed this topic.

https://www.thethingsindustries.com/docs/integrations/webhooks/

Which server is example.com?

From the question about example.com I gather that it can’t be right.
Good hint! So I tried https://eu1.cloud.thethings.network. So I try:

curl --location \ --header 'Authorization: Bearer NNXXX.My_Token_with_enable_Write_downlink_application_traffic' \ --header 'Content-Type: application/json' \ --header 'User-Agent: my-integration/my-integration-version' \ --request POST \ --data '{"downlinks":[{ "frm_payload":"AwEB", "f_port":2 }] }' \ 'https://eu1.cloud.thethings.network/api/v3/as/applications/my-application-id/devices/eui-my_end-device_id/down/push'
"code":3,
   "message":"error:pkg/errors:validation (invalid `end_device_ids`: embedded message failed validation)",
   "details":[
      {
         "@type":"type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
         "namespace":"pkg/errors",
         "name":"validation",
         "message_format":"invalid `{field}`: {reason}",

at least I get something back, but an error:

Checked it again, the endDevice-Id is correct

It’s a bit hard to read the JSON - can you edit your post and use the </> tool so we can pick through it.

Also, what OS are you using?

1 Like

Thanks for the help.
It works as it should.
As soon as you do it right, it works.
Thanks again.

1 Like