I’m having trouble saving a response Id as an environment variable as the value is given as a 64 bit integer. I understand that the issue is with how javascript handles big numbers…i.e. the last three digits of my 19 digit integer get rounded when saving as a variable and therefore do not match what is seen in the response body in the build pane.
I’d be happy (at this moment) to save the variable as a string - just to see it working but cannot get this to work…I still end up with a rounded value saved.
Maybe I am implementing stringify and toString incorrectly so could do with help saving this value as such as a starting point.
I am fairly new to coding of any sort. I took (completed) Valentin Despa’s course on Udemy to achieve a specific goal and have managed to achieve some success with the Zenfolio API but am struggling with this.
The response looks like this and I’m after saving result.Id correctly
{
"result": {
"$type": "Group",
"Caption": "Caption for Group",
"ParentGroups": [
1960581322357022743,
1960581321825460534,
1960581321642492582
],
"Elements": [],
"PageUrl": "http://msimpson.zenfolio.com/f644439406",
"TitlePhoto": null,
"MailboxId": "Z6X1BDM7KRCF",
"TextCn": 0,
"ImmediateChildrenCount": 0,
"Id": 1960581322055966062,
"GroupIndex": 6,
"Title": "Created with the API by Mike"
},
"error": null,
"id": 0
}
The following saves the value rounded:
let resultId = (pm.response.json().result.Id).toString();
pm.environment.set(“resultAsString”, resultId);
I have purposefully not used the following to see if it made any difference:
let requestResponse = pm.response.json();
Thanks for any pointers.
Mike