Add double quotes to string which is saved in environment variable

Hi, everyone!
Can you please help me with adding double quotes in the environment variable that I saved from the response body?
I’m GETing that response body
image
And I need to save “codes” field in the variable (globals, environment doesn’t matter) with double quotes to use this String in another POST request’s body (body with JSON format). Or maybe in the POST request’s body, I can add double quotes? I mean smth like that: { “sntins”: “”" + {{GETcodes}} + “”"}
I’m setting variable simply like that:
var response = pm.response.json();
pm.environment.set(“GETcodes”, response.codes);

I also tried to save with double quotes like that:
var jsonData = JSON.parse(responseBody);
var parsedData = “”;
for(var i=0;i<jsonData.length;i++){
parsedData = parsedData +"“codes” : “” +jsonData.codes+"", ";
console.log(parsedData);
postman.setEnvironmentVariable(“parsedNamesResponse”, parsedData);

But it didn’t help(

Hi @_zh0Ra Welcome to the community :slight_smile:

Could you please try the below snippet:

var response = pm.response.json();
pm.environment.set(“GETcodes”, JSON.stringify(response.codes));

Hi @jency.stella19!
Didn’t expect a quick response, thank you very much! This is what I was looking for.

1 Like