Hi All,
In response content im getting the error as shown below.
I want to change only the code field and return the same respone with the new code filed
Eg:
{"propertyId":"B5","errors":[{"code":"CS50061","field":"playerId","message":"Invalid Patron"}]}
TO
{"propertyId":"B5","errors":[{"code":"401","field":"playerId","message":"Invalid Patron"}]}
How can I do it using extract variables.
Solved! Go to Solution.
You shouldn't use Extract Variables for that purpose. I wouldn't.
I would use a simple JavaScript Callout to modify that payload.
var c = JSON.parse(context.getVariable('response.content')); if (c.errors && c.errors[0] && c.errors[0]].code) { c.errors[0].code = 401; context.setVariable('response.content', JSON.stringify(c, null, 2)+'\n'); }
You might want to add some further logic to check if the errors field is what you expect, and so on.
You shouldn't use Extract Variables for that purpose. I wouldn't.
I would use a simple JavaScript Callout to modify that payload.
var c = JSON.parse(context.getVariable('response.content')); if (c.errors && c.errors[0] && c.errors[0]].code) { c.errors[0].code = 401; context.setVariable('response.content', JSON.stringify(c, null, 2)+'\n'); }
You might want to add some further logic to check if the errors field is what you expect, and so on.
User | Count |
---|---|
7 | |
2 | |
2 | |
2 | |
1 |