Passing parameters to an HTTP GET request

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-

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!

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.

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;

Nope, I havent

Works, much thanks!

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