API-Key (header x-api-key) in http request

I want to create a simple query on a cloud-based software.
I get the message "ENETUNREACH" in all tried versions
I know that I have to set the header x-api-key with the key.
I do this GET query in Postman = Y> works
I do the query in Node.js => works
But I just don't get the part in the node red.
Here is the information I need to create the GET query:

Url: https://api.airkey.evva.com:443/cloud/v1/customer
x-api-key: xxxx
Content-Type: application / json

Currently it seems to me that I am not that far away from it:
[{"id":"340899c6.d3b816","type":"tab","label":"Airkey API Test","disabled":false,"info":""},{"id":"49a54f77.b8319","type":"function","z":"340899c6.d3b816","name":"set payload and headers","func":"msg.headers = {};\nmsg.headers['x-api-key'] = 'xxx';\nmsg.headers['Content-Type'] = 'application/json';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":220,"wires":[["dec76f59.1b076"]]},{"id":"32f4730e.9bad8c","type":"inject","z":"340899c6.d3b816","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":180,"y":220,"wires":[["49a54f77.b8319"]]},{"id":"404fc276.fd378c","type":"debug","z":"340899c6.d3b816","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":220,"wires":[]},{"id":"dec76f59.1b076","type":"http request","z":"340899c6.d3b816","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.airkey.evva.com:443/cloud/v1/customer","tls":"","persist":false,"proxy":"","authType":"","x":610,"y":220,"wires":[["404fc276.fd378c"]]}]

I hope someone can help me and tell me what I'm doing wrong.
Many thanks for the support.

your flow is completely corrupted.

can you paste it again?

In order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```

See this post for more details - How to share code or flow json

Hi @Bigberg

At the end of your function you need to return msg.

I adjusted it (the corrupt flow)

in the functions node I have the "return msg;" inside

here is the function node:
msg.headers = {};
msg.headers ['x-api-key'] = 'xxx';
msg.headers ['Content-Type'] = 'application / json';
return msg;

On the machine running node-red are you able to ping api.airkey.evva.com. Are you running node-red in a container such as Docker? If so does the ping work from within the container?

Thanks for the input.
Yes, the goal is achievable. I am also shown the IP with the ENETUNREACH report.
Node-red runs on a Raspberry and not in a Docker.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.