Edit request body in Pre-request script

What I’ve found is the easiest is to just set it all to a variable. So take what you have and modify it slightly:

let body = {
    mode: 'raw',
    raw: JSON.stringify({
        licenseUsername: 'username',
        licensePassword: 'password'
    }),
    options: {
        raw: {
            language: 'json'
        }
    }
}
pm.variables.set('body', JSON.stringify(body));

Then in the body of your request, just use the variable
image

3 Likes