[Archivesspace_Users_Group] Batch delete

Chris Fitzpatrick Chris.Fitzpatrick at lyrasis.org
Thu Jun 5 06:00:48 EDT 2014

Hi Steven,

To send a list via a POST command, you need to put a [] in the parameter


Like this:

curl -H "X-ArchivesSpace-Session: $TOKEN" -d "record_uris[]=/repositories/2/resources/3&record_uris[]=/repositories/2/resources/4" http://localhost:8089/batch_delete

best, chris.

Chris Fitzpatrick | Developer, ArchivesSpace
Skype: chrisfitzpat  | Phone: 918.236.6048
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Steven Majewski <sdm7g at virginia.edu>
Sent: Thursday, May 29, 2014 8:50 PM
To: Archivesspace Users Group
Subject: Re: [Archivesspace_Users_Group] Batch delete

Apparently, there is also a  /batch_delete method, but I haven't yet managed to figure out
how to give it the correct record_uris parameter.  I've tried several different ways of encoding
record_uris (as a plain string, a json string, a json list of strings... ), and several different resource URIs,
but I always seem to get something like:

{"error":{"record_uris":["Wanted type [String] but got '/repositories/25/resources/3610/tree'"]}}

POST /batch_delete


Carry out delete requests against a list of records


[String] record_uris -- A list of record uris


200 -- deleted

Also: attempting to delete an empty repository from the admin interface yields the error:

Cannot delete - repository not empty

even though the admin browse  shows  no Accessions, Resources or Digital Objects in the repo,
and  API /repositories/:repo_id/resources?all_ids=true   returns  empty  [ ] .

However, after doing a 'transfer repository' to another repo, I am able to delete the first repository.

Since we're still testing, we've had to frequently resort to just deleting all of the mysql database
tables and starting over fresh.

- Steve.

On May 28, 2014, at 11:38 AM, Bridger Dyson-Smith <bdysonsm at utk.edu<mailto:bdysonsm at utk.edu>> wrote:

On 05/28/2014 11:36, Steven Majewski wrote:

On May 28, 2014, at 9:15 AM, Bridger Dyson-Smith <bdysonsm at utk.edu<mailto:bdysonsm at utk.edu>
<mailto:bdysonsm at utk.edu>> wrote:

Hi all,

Is there a batch process for deleting/backing out of an import job? Or
is there some other work-around to accomplish a bulk resource removal?


You can delete all of the resources in a repo thru the backend web api
with something like this:

for ID in $( curl_as_osx admin admin
"$REPO/repositories/$REPO_ID/resources?all_ids=true" | tail -1 | tr
'[],' ' ' )
curl_as_osx admin admin $DELETE
$REPO/repositories/$REPO_ID/resources/$ID | tail -1 | json_pp

i.e. First curl gets the list of resource ids in that repo. Loop over
the list and do a HTTP DELETE on each resource.

If you don't want to delete them all, there may be a way to do a finer
selection thru the search API, but I haven't figure out how to do it.
Perhaps something like this  is easier to do in the jirb console.

- Steve Majewski

Hi Steve -
thanks for that snippet - it is much appreciated.

Archivesspace_Users_Group mailing list
Archivesspace_Users_Group at lyralists.lyrasis.org<mailto:Archivesspace_Users_Group at lyralists.lyrasis.org>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20140605/1ee8e587/attachment.html>

More information about the Archivesspace_Users_Group mailing list