How to pass query params to API

Hi everyone,

I'm trying to post payload to API using HTTP request where i'm trying to pass query params as shown below but it is not getting appended with URL

msg.query = {
    accountID: 'XXXX',
    apiKey: '6dxxxxxxxxxxx',
    edgeEUI: '91xxxxxxxxxxxxx'
};

return msg;

HTTP request node configuration is as shown below

Node output:

{
    "_msgid": "5d42df85bbc5ec94",
    "payload": {
        "statusCode": 400,
        "message": "Bad Request",
        "description": "Missing parameters"
    },
    "statusCode": 400,
    "responseUrl": "https://api.fogwing.net/api/v1/iothub/postPayload/withApiKey",
    "redirectList": [],
    "retry": 0,
    "query": {
        "accountID": "XXXX",
        "apiKey": "6dxxxxxxxxxxx",
        "edgeEUI": "91xxxxxxxxxxxxx"
    },
    "headers": {
        "server": "nginx/1.14.0 (Ubuntu)",
        "date": "Sun, 14 May 2023 12:16:42 GMT",
        "content-type": "application/json",
        "content-length": "77",
        "connection": "close",
        "x-node-red-request-node": "65cd1783"
    }
}

Try this way, I have working nodes setup like this

msg.headers = {
   'accountID': 'XXXX',
   'apiKey': '6dxxxxxxxxxxx',
   'edgeEUI': '91xxxxxxxxxxxxx'
};

return msg;

That worked thanks

1 Like

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