17KB
17KB

Reputation: 100

Postman: Query body values as number

In Postman, is there a way to send the value of parent1[child] as a number rather than a string? postman query body x-www-form-urlencoded

I am aware that I could simply do it like this: postman query body raw JSON

However, my specific case requires it to be sent as x-www-form-urlencoded.

Upvotes: 3

Views: 13199

Answers (1)

If you're trying to send the POST body as JSON (application/json), you need to use the "raw" or "binary" option. "x-www-form-urlencoded" (application/x-www-form-urlencoded) is a different data format that doesn't distinguish between strings and numbers. You'll have to parse the data out by hand on the other end if you want to use x-www-form-urlencoded. That is, the receiving end will have to know whether a field should contain text or numeric data and handle it accordingly. If you need to make this determination on the sending side, you should not plan to use x-www-form-urlencoded because it doesn't support that distinction.

Your top example is sending this POST body:

parent1[child]=200&parent2[child]=Hello%20World

Your bottom example is sending this completely different POST body:

{
    "parent1": {
        "child": 200
    },
    "parent2": {
        "child": "Hello World"
    }
}

Upvotes: 3

Related Questions