let deleteid = pm.collectionVariables.get("deleteid");
pm.globals.get("LastDeviceID");
if (!deleteid || deleteid.length == 0) {
deleteid = [null, "[555]", "abc", "f1r4.y6u8,o9", "{{LastDeviceID}}"];
}
let currentdeleteid = deleteid.shift();
pm.collectionVariables.set("delete_id", currentdeleteid);
pm.collectionVariables.set("deleteid", deleteid);
And in the Params tab, is the {{delete_id}} variable which checks for null, "[555]", "abc", "f1r4.y6u8,o9", "{{LastDeviceID}}". When it comes to "how I save 2 last variables, I used the code below at one of my GET method:
pm.test("Body has 'id' string", function () {
pm.expect(pm.response.text()).to.include("id");
const responseJson = pm.response.json();
let arr = responseJson;
let LastDeviceID = arr.length - 1;
let LastDeviceID1 = arr.length - 2;
let TwoUsers = [arr[LastDeviceID].id, arr[LastDeviceID1].id]
pm.collectionVariables.set("LastDeviceID", TwoUsers);
console.log(pm.collectionVariables.get("LastDeviceID"))
console.log(pm.collectionVariables.get("LastDeviceID")[0])
});
You might be true, it will pass it as a string, but it could work nicely if I could somehow add “[” and “]” at end of that string because to make DELETE work, id must be in square brackets, either [20] or [20,19].