# How to pass query params to API

**URL:** <https://discourse.nodered.org/t/how-to-pass-query-params-to-api/78413>\
**Category:** General\
**Tags:** http-request, function-node\
**Created:** [14 May 2023 12:29 UTC](https://discourse.nodered.org/t/how-to-pass-query-params-to-api/78413 "2023-05-14T12:29:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eldho1416](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@eldho1416](https://discourse.nodered.org/u/eldho1416)\
**Post date:** [14 May 2023 12:29 UTC](https://discourse.nodered.org/t/how-to-pass-query-params-to-api/78413/1 "2023-05-14T12:29:44Z")

</div>

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

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

return msg;

```

HTTP request node configuration is as shown below

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f15a41234ae6900b8c3f06715aea4e1b3ef4f1b.png)

Node output:

```auto
{
    "_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"
    }
}
```

---

<div class="post-metadata">

**Author:** ![umtksa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/umtksa/32/38322_2.png) [@umtksa](https://discourse.nodered.org/u/umtksa)\
**Post date:** [14 May 2023 12:59 UTC](https://discourse.nodered.org/t/how-to-pass-query-params-to-api/78413/2 "2023-05-14T12:59:22Z")

</div>

Try this way, I have working nodes setup like this

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

return msg;

```

---

<div class="post-metadata">

**Author:** ![eldho1416](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@eldho1416](https://discourse.nodered.org/u/eldho1416)\
**Post date:** [14 May 2023 13:05 UTC](https://discourse.nodered.org/t/how-to-pass-query-params-to-api/78413/3 "2023-05-14T13:05:27Z")

</div>

That worked thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 May 2023 13:05 UTC](https://discourse.nodered.org/t/how-to-pass-query-params-to-api/78413/4 "2023-05-28T13:05:36Z")

</div>

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