Inject Json in "Body" using a http request node dont work

iam trying to collect data from an API
If you just request the API without filters you get every data, but i need to filter it
I have set it up in postman and it is working with and without the filtering.

In node red i get it to work to request all data, but i cant get the "filtering" to work
The request returns all data and not the filtered data

To do the filtering In postman i add Content-Type : application/json in Headers and in Body i have this

    "operator": "and",
    "filters": [
            "key": "survey",
            "values": ["mI7Utyd5igBVyLfR_E2F2P6dL0bPMfA9juUHyiPUgq7"],
            "comparison": "is"

And in Node red i inject the same into msg.body and add Content-Type : application/json as a header in http-request

When looking at the debug i see this result under Body

body: object
operator: "and"
filters: array[1]
0: object
key: "survey"
values: array[1]
0: "mI7Utyd5igBVyLfR_E2F2P6dL0bPMfA9juUHyiPUgq7"
comparison: "is"
statusCode: 200

And the payload should return 5 counts but return 110

payload: object

next: ""

previous: null

count: 110

answers: array[100]

This is probably something simple but iam realy new to this and any help is apreshiated

Here are some info about the API


Did you set the correct type? The default for the request node is GET but that will probably not pass the JSON correctly, you should be using PUT most likely.

Thanx for the reply

IĀ“ve set it to POST according to the API documentation, now tried with PUT but got the response "PUT is not allowed"

OK, I don't have access so I can't test it out I'm afraid. Not much else I can do.

This is where you might be going wrong.

The body for a POST request is taking from msg.payload.

  • set msg.payload to the filter as required
  • set the content type to application/json in the request node
  • set method to POST
1 Like

Yes :slight_smile: that worked, thanx

1 Like

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