# Postman delete multiple resource IDs

**URL:** <https://community.postman.com/t/postman-delete-multiple-resource-ids/42142>\
**Category:** Help Hub\
**Created:** [December 16, 2022, 1:09pm UTC](https://community.postman.com/t/postman-delete-multiple-resource-ids/42142 "2022-12-16T13:09:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [December 19, 2022, 1:35pm UTC](https://community.postman.com/t/postman-delete-multiple-resource-ids/42142/2 "2022-12-19T13:35:17Z")

</div>

The following should work. (This is running against postman echo and I’ve just put the {{id}} into the URL instead of the body.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/0/b/0be7efeb1caf6d1d434362df0aaa39ef5c9ffb50.png)

Pre-request script.

```auto
var array = JSON.parse(pm.collectionVariables.get("resources"));

if(array.length === 0){
    array = [
        "ba08971c-83de-777c-beb2-2dbe91e727e6",
        "c6ec9412-e19e-999-bcc8-0a9900f3c0ba",
        "268e8bd9-3381-0000-81d3-38fd4fa11110"
    ];
}

pm.test("pre-req array is not empty", () => {
    pm.expect(array).to.be.an("array").that.is.not.empty; 
});

var currentResource = array.shift();

pm.collectionVariables.set("id",currentResource);
pm.collectionVariables.set("resources", JSON.stringify(array));

```

Tests tab.

```auto
var array = JSON.parse(pm.collectionVariables.get("resources"));

var expectedResponse = pm.collectionVariables.get("id");
var actualResponse = pm.response.json().args.test;

pm.test(`tests-tab id = ${expectedResponse}`, () => {
    pm.expect(actualResponse).to.eql(expectedResponse); 
});

if (array.length > 0){
postman.setNextRequest("multiple_resources_delete_inonego");

} else {
postman.setNextRequest(null);
}

```

Run history. One iteration (run three times).

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/1/9/1958f36f0497807720c5551fab799b05853444a8.png)

I think the bit you are missing is the storing of the array. Variables are stored as strings, so you have to Stringify them when storing, and JSON.parse when retrieving otherwise they will just be viewed as a string (not an array).

However I swear that the example I had previously saved and tested for this exact scenario didn’t need to do this.

It took me a while to work out what was going wrong, and amending the storing and retrieving of the array fixed it.

You need to have something in the resources array, or the first line of the pre-request script will error (as it needs something, even if its a blank “” array. It can’t just be empty though.

Pretty sure I didn’t need to do this previously either.

Not sure if something changed with how variables are stored in Postman 10, as it took me while to get this working again but it does work.

---

_[View the full topic](https://community.postman.com/t/postman-delete-multiple-resource-ids/42142)._
