I got this response :
"success": true,
"data": {
"638f2a029a8253170d1272c7": {
...
"id": "638f2a029a8253170d1272c7", // this is the value i want
"permissions": {
...
}
},
...
}
}
the value I want is the id: "id": "638f2a029a8253170d1272c7"
I tried this:
let responseData = pm.response.json();
pm.environment.set("customerid", responseData.data[0].id);`
but getting error
2
Answers
you can get the id field value from JSON in this way.
JSONObject jsonObj = new JSONObject(responseJson);
System.out.println(jsonObj.getString("id));
Correct code would be: