Working with files convert integer into string

Hi,

In my collection i created a POST request like this:

  • Select: POST
  • Url: {{url}}/api/v1/clients
  • Body:
    o x-www-form-urlencoded
    o Bulk Edit:
    estate:{{clientsEstateTemoin}}
    id_externe:{{clientsIdExterneTemoin}}
    langue:{{clientsLangueTemoin}}
    nom:{{clientsNomTemoin}}

Manual way, OK:
If i set the “clientsEstateTemoin” variable in the “EDIT COLLECTION > Variables” as 12 it will be sent as 12 via the body when i use the “Send” blue button

Run Way, KO:
If i pass through “COLLECTION RUNNER”, select a json file with:
[
{
“clientsEstateTemoin”: 12
}
]
and run it i get a 400 cause “clientsEstateTemoin” has been sent has “12”, not 12 via the body.

Where do in need to specify to not convert all the values at strings ?

Regards,
Emeon.

Hey @Emeon

How you specifying the variable in the POST body?

Is it like "key": "{{var}}" or key: {{var}}

Hi @dannydainton

It’s key:{{var}}

If you add something like to the pre request script:

let value = pm.iterationData.get('clientsEstateTemoin')

pm.variables.set("clientsEstateTemoin", parseInt(value))

Would that send it as an int? Make sure that if you’re making changes in the request builder, save them before running the collection in the Runner.

I’m going off memory and not at my machine at the moment so I might be incorrect here :grin:

It worked :ok_hand:

Thanks a lot !

1 Like