# Bug: pm.request.body.update() doesn't work

**URL:** <https://community.postman.com/t/bug-pm-request-body-update-doesnt-work/12828>\
**Category:** Help Hub\
**Created:** [May 22, 2020, 12:17pm UTC](https://community.postman.com/t/bug-pm-request-body-update-doesnt-work/12828 "2020-05-22T12:17:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![v.mukhin](https://avatars.discourse-cdn.com/v4/letter/v/a6a055/32.png) [@v.mukhin](https://community.postman.com/u/v.mukhin)\
**Post date:** [May 22, 2020, 12:17pm UTC](https://community.postman.com/t/bug-pm-request-body-update-doesnt-work/12828/1 "2020-05-22T12:17:23Z")

</div>

current body (raw):

> ```
> {
> "data": {
> "resolutions": [
> {
> "id": "20224346",
> "payStateId": 1,
> "resolutionStateId": 666,
> "moveStateId": 666,
> "state_date": "2020-04-05 12:12:21.000"
> }
> ]
> }
> }
> 
> ```

pre-request script:

> ```
> pm.request.body.update(JSON.stringify({
> 'payload': btoa(pm.request.body),
> 'signature': pm.collectionVariables.get('signature')
> }));
> 
> ```

So, despite the fact “pm.request.body” is modified before sending data, it still sends original body.

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [May 23, 2020, 1:54am UTC](https://community.postman.com/t/bug-pm-request-body-update-doesnt-work/12828/2 "2020-05-23T01:54:48Z")

</div>

As far as I remember, pm.request.body is immutable for some reason. 🙄

---

<div class="post-metadata">

**Author:** ![v.mukhin](https://avatars.discourse-cdn.com/v4/letter/v/a6a055/32.png) [@v.mukhin](https://community.postman.com/u/v.mukhin)\
**Post date:** [May 25, 2020, 7:08am UTC](https://community.postman.com/t/bug-pm-request-body-update-doesnt-work/12828/3 "2020-05-25T07:08:03Z")

</div>

Well, there is a separate method defined [url](http://www.postmanlabs.com/postman-collection/RequestBody.html), so that’s a bit weird to make it immutable.  
Also, in console I see that pm.request.body is updated after script, but on backend I receive original request

---

<div class="post-metadata">

**Author:** ![eborel](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@eborel](https://community.postman.com/u/eborel)\
**Post date:** [June 4, 2020, 9:57am UTC](https://community.postman.com/t/bug-pm-request-body-update-doesnt-work/12828/4 "2020-06-04T09:57:42Z")

</div>

I have the same issue. I want to remove a repeating property in my JSON input and update the body but what is sent is the original one.

Here is my pre-request script:

```
var body = pm.request.body.toString();

pm.request.body.update({
    mode: "raw",
    raw: body.replace(/"id":"[^"]*",/g, '')
});

// Print the correct output, with all "id" property removed. 
// But what is actually sent is the original, unmodified output.
console.log(pm.request.body.raw);

```

This is quite frustrating 😕

EDIT: to be clear I followed what the actual implementation seems to require (see [here](https://www.postmanlabs.com/postman-collection/collection_request-body.js.html#line36))

EDIT2: I’m also following this [issue on github](https://github.com/postmanlabs/postman-app-support/issues/4808), but it seems to be going nowhere as of now…
