Hi All,
I’m trying to transform the JSON body of the request into a string formatted as ‘key1=value1&key2=value2&key3=value3’. I have a regular JavaScript line that works great:
const bodySignParams = Object.entries(params).map(([key, val]) => key + ‘=’ + val).join(‘&’);
where ‘params’ is a JSON object
If I use it in an online Javascript sandbox, the result is perfect. If I try this in Postman, it interprets every character and not the key/value pair, even if I do JSON.parse(params) – so if the input is
{ “ba”: “sheep”, “have”: “wool” }
the output is
0={&1=“&3=b&4=a&5=” – you get the idea.
in this case, the output should be
ba=sheep&have=wool
How can I get Postman to treat it as key/value pairs instead of a string?
This is in the pre-request script at the collection level.