Currently Not able to use special characters in Request tests tab and its displaying error

Currently Not able to use special characters in Request tests tab and its displaying error

I am getting the response like this.

But in postman If I try same json path, its giving error. Any way to avoid it or any workaround is there.

Currently able to solve by ```
pm.environment.set(“nameBoxElement”, _.values(response.value)[0])


But was curious to know if there is any xpath or regular expression I can constuct to get the required dynamic element value taking static text as reference kind.

![image|690x302](upload://385LTewaOKgTMUNc7vR1Htf1CD2.png)

Last Image didn’t uploaded properly.

Hi @vishnuprakash9845

Here are two examples of RegEx’s I’ve used;

const response = pm.response.text();
let authCode = response.match(/authorizationCode = '(.*?)';/g);
//remove first and last characters with slice;
console.log(authCode[0].slice(21, -2));

var body = responseBody;
if(body!=null && body.length>0){
    var array = new RegExp("secret\=(.*?)\"").exec(body);
    if(array!=null && array.length>0 && array[1]!=null){
        console.log(array[1]);
    }
}

Hope it helps…

1 Like

This works, thank you.