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

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:

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

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

Well, there is a separate method defined url, 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

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();

    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.

This is quite frustrating :confused:

EDIT: to be clear I followed what the actual implementation seems to require (see here)

EDIT2: I’m also following this issue on github, but it seems to be going nowhere as of now…

1 Like