How to pass boolean value in the body parameters?

I tried like below, looks like it is going as a string. How to pass the value as boolean type?
ERROR: 400 - {“type”:“invalid_request_error”,“message”:“Validation Error”,“fields”:{“dynamic_ip_required”:[“expected bool”],

image

Hey @mahesh,

Would you be able to provide a bit more context for the question? It is difficult to determine what you are trying to accomplish just a snippet of an error message and part of a screen capture.

Thanks,

Jason

Hi Jason,

I am trying to send the body parameters using API Post request. One of the body parameter needed is a boolean type.

@mahesh check the example below, hope that helps.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://webhook.site/7da85680-f31e-455c-8f7d-f37ad26f6348",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "{  \"isPerson\": true  }"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        540,
        310
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@Tephlon When you use the UI to set the parameters, they are sent as strings. Check the image below, so the data is being sent as { isPerson: “true” } and @mahesh wanted to send it as { isPerson: true }. This can be achieved by sending the parameters as raw. Maybe in the future would come handy to add the type the value should be sent to.

1 Like

Thanks @RicardoE105! That clears things up a bit for me. Completely makes sense now!

Personally, when I think of these parameters, I mentally envision them like the parameters that are passed along in an URL. Everything is passed as text and is then interpreted on the other side when being assigned.

Actually theoretically it should also work if he would sets the parameter as an expression with {{true}}

3 Likes

@jan this worked perfectly. Thanks a lot
@RicardoE105 thanks for the help.

You guys are awesome !!

1 Like

Really glad to hear that it works!

There are often multiple solutions for the same problem is just about finding the best one for your situation.

Have fun!

1 Like