# Pre request decode is not working

**URL:** <https://community.postman.com/t/pre-request-decode-is-not-working/16160>\
**Category:** Help Hub\
**Created:** [September 23, 2020, 2:13pm UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160 "2020-09-23T14:13:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom.112](https://avatars.discourse-cdn.com/v4/letter/t/b3f665/32.png) [@tom.112](https://community.postman.com/u/tom.112)\
**Post date:** [September 23, 2020, 2:13pm UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/1 "2020-09-23T14:13:24Z")

</div>

Hello.

I decode config params and I update the uri, but the decode is not applied.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/c/9/c9466b972e7295a0d5aa6926617cfe5aafc965df.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 23, 2020, 3:43pm UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/2 "2020-09-23T15:43:13Z")

</div>

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:

```auto
pm.request.url.query.upsert({key: "paramName", value: "paramValue"})

```

---

<div class="post-metadata">

**Author:** ![tom.112](https://avatars.discourse-cdn.com/v4/letter/t/b3f665/32.png) [@tom.112](https://community.postman.com/u/tom.112)\
**Post date:** [September 23, 2020, 11:56pm UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/3 "2020-09-23T23:56:41Z")

</div>

upsert doesn’t help.

upert is same with “add”.

Is any other way to update params value ?

---

<div class="post-metadata">

**Author:** ![amit](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/amit/32/2056_2.png) [@amit](https://community.postman.com/u/amit)\
**Post date:** [September 24, 2020, 12:14am UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/4 "2020-09-24T00:14:39Z")

</div>

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](https://tools.ietf.org/html/rfc3986#section-2.2) these must be encoded and since ‘`#`’ is reserved for [fragment identifiers](https://tools.ietf.org/html/rfc3986#section-2.2), it is encoded before being included as the parameters value

[https://tools.ietf.org/html/rfc3986#section-2.2](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.

---

<div class="post-metadata">

**Author:** ![tom.112](https://avatars.discourse-cdn.com/v4/letter/t/b3f665/32.png) [@tom.112](https://community.postman.com/u/tom.112)\
**Post date:** [September 24, 2020, 12:28am UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/5 "2020-09-24T00:28:35Z")

</div>

@amit  
Is there anything that can be set to not encode #?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/1/3130b7ac088b03329b0a7469ebcb075fb934bd3e.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 24, 2020, 5:38am UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/6 "2020-09-24T05:38:48Z")

</div>

`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.

```auto
pm.request.url.query.upsert({key: "config", value: decoded})

```

---

<div class="post-metadata">

**Author:** ![tom.112](https://avatars.discourse-cdn.com/v4/letter/t/b3f665/32.png) [@tom.112](https://community.postman.com/u/tom.112)\
**Post date:** [September 24, 2020, 7:36am UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/7 "2020-09-24T07:36:11Z")

</div>

```auto
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$

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/a/aafd1846cb63f65b0959dd120094c9779b7e006b.png)

First I changed it manually.  
thanks…

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 24, 2020, 7:49am UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/8 "2020-09-24T07:49:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tom.112](https://avatars.discourse-cdn.com/v4/letter/t/b3f665/32.png) [@tom.112](https://community.postman.com/u/tom.112)\
**Post date:** [September 24, 2020, 8:03am UTC](https://community.postman.com/t/pre-request-decode-is-not-working/16160/9 "2020-09-24T08:03:46Z")

</div>

there is no example…so that’s why I quest in it.

- now : GET http:// ~~~/~~~?config=!@%23$
- expected outcome : GET http:// ~~~/~~~?config=!@#$

===

var decoded = decodeURIComponent(reqParameters.config);

console.log(decoded); -\> “!@#$” ok

pm.request.url.query.upsert({key : “config”, value : decoded}); -\> !@%23$ failed  
☹
