# Passing parameters to an HTTP GET request

**URL:** https://discourse.nodered.org/t/passing-parameters-to-an-http-get-request/75575
**Category:** General
**Created:** [22 February 2023 09:47 UTC](https://discourse.nodered.org/t/passing-parameters-to-an-http-get-request/75575 "2023-02-22T09:47:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![milner236](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@milner236](https://discourse.nodered.org/u/milner236)
#### Post date: [22 February 2023 09:47 UTC](https://discourse.nodered.org/t/passing-parameters-to-an-http-get-request/75575/1 "2023-02-22T09:47:05Z")

</div>

Hey folks, came across something quite odd.

I'm trying to run a GET request using a function node followed by an http node.  
I cant seem to manage to pass parameters to the request, seems like the request goes through as if there were no parameters set.

This is the content of the function node-

```auto
msg.headers = {
    "x-access-token": msg.token,
    "Content-Type": "application/json"
}

msg.method = "GET"
msg.url = "myendpointurl" ;

msg.payload = {
    "from" : "1674378736000",
    "to" : "1674897136000",
    "debug": true
}

return msg;

```

Needless to say that using postman the request goes through including the parameters just fine. What am I doing wrong?

\*\* I dont receive an error, the request goes through just fine, but it ignores the parameters set @ msg.payload

Thanks as always!

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [22 February 2023 09:49 UTC](https://discourse.nodered.org/t/passing-parameters-to-an-http-get-request/75575/2 "2023-02-22T09:49:52Z")

</div>

Have you selected `Append to query-string parameters` for payload in the http request node.  
or set the payload to the query string direct in msg.url  
e.g.

```auto
msg.headers = {
    "x-access-token": msg.token,
    "Content-Type": "application/json"
}

msg.method = "GET"

msg.payload = {
    "from" : "1674378736000",
    "to" : "1674897136000",
    "debug": true
}
let query_string = Object.entries(msg.payload).map(params => {
    return `${params[0]}=${params[1]}`;
}).join("&")
msg.url = encodeURI("myendpointurl?" + query_string);
return msg;

```

---

<div class="post-metadata">

### Author: ![milner236](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@milner236](https://discourse.nodered.org/u/milner236)
#### Post date: [22 February 2023 09:52 UTC](https://discourse.nodered.org/t/passing-parameters-to-an-http-get-request/75575/3 "2023-02-22T09:52:43Z")

</div>

Nope, I havent

---

<div class="post-metadata">

### Author: ![milner236](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@milner236](https://discourse.nodered.org/u/milner236)
#### Post date: [22 February 2023 10:14 UTC](https://discourse.nodered.org/t/passing-parameters-to-an-http-get-request/75575/4 "2023-02-22T10:14:56Z")

</div>

Works, much 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: [8 March 2023 10:15 UTC](https://discourse.nodered.org/t/passing-parameters-to-an-http-get-request/75575/5 "2023-03-08T10:15:35Z")

</div>

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