Search code examples
node-red

Node-Red & The Things Network


I have been trying for most of the weekend to try and figure out how to retrieve data using Node-Red on a Raspberry Pi from the ‘Data Storage’ on The Things Network.

If I use Swagger, I can retrieve data, and as a first step, I am trying to replicate this functionality within Node-Red, but I can’t seem to get it working.

So far I have setup a simple flow:-

Inject => HTTP Get Request => Debug output.

I have tried setting various ways in the inject node, but no matter what I try and do I get ‘Not Authorised’. I’ve got the credentials “Content-Type":"application/json” "Authorization":"key ttn-account-v2.hKfO9VxxxxxxxxxxxxxxxxxxxxxfwZFU6G4A080s”

I’ve put these in the msg.header, the msg.payload, and others, without any really success.

I would really appreciate any ideas on how to get it to work.

Edit: As requested, here is info as to how I am setting the data. The inject node has properties that are setting the msg.

inject node properties.

I have tried a few different combinations, but no success.


Solution

  • msg.headers should contain both the Content-Type and the Authorization values

    e.g.

    {
      "Authorization": "key ttn-account-v2.hKfO9VxxxxxxxxxxxxxxxxxxxxxfwZFU6G4A080s",
      "Content-Type": "application/json"
    }