Hello.
I decode config params and I update the uri, but the decode is not applied.
Hey @tom.112
Welcome to the community!
Iâm not sure what youâre trying to do here but to replace the query param value for the request you would need to use:
pm.request.url.query.upsert({key: "paramName", value: "paramValue"})
upsert doesnât help.
upert is same with âaddâ.
Is any other way to update params value ?
Hey @tom.112 when you say upsert doesnât help? What exactly didnât work?
Was the parameter value not update in your case? Or is there something else you were expecting that didnât happen?
Iâm taking a wild guess here and assuming you are expecting the data not to be encoded? If thatâs the case, the RFC states these must be encoded and since â#
â is reserved for fragment identifiers, it is encoded before being included as the parameters value
https://tools.ietf.org/html/rfc3986#section-2.2
If data for a URI component would conflict with a reserved
characterâs purpose as a delimiter, then the conflicting data must be
percent-encoded before the URI is formed.
@amit
Is there anything that can be set to not encode #?
upsert
is slightly different that add
, upsert
will update an existing key if present or add a new one if itâs not. The add
method would just add a new one.
Your syntax is slightly wrong in the code, it needs to be in an object with key
and value
properties.
pm.request.url.query.upsert({key: "config", value: decoded})
pm.request.url.query.upsert({key: "config", value: decoded})
Um, am I right?
umâŚI couldnât solve it.
console.log(decoded) â !@#$
pmâŚupsert({âŚ}) â !@%23$
First I changed it manually.
thanksâŚ
What is the expected outcome? What do you think the request should look like?
Do you have a hardcoded example of where youâre trying to achieve?
there is no exampleâŚso thatâs why I quest in it.
===
var decoded = decodeURIComponent(reqParameters.config);
console.log(decoded); -> â!@#$â ok
pm.request.url.query.upsert({key : âconfigâ, value : decoded}); -> !@%23$ failed