Post

2 followers Follow
0
Avatar

How to do bulk delete of Expense Sheets using API 2.0

We are developing an interface for expense sheets from a legacy system to Clarizen and would like to clean out uploaded data between test runs. 

Each test run is for 1200 projects, so deleting the expense sheets in the UI is too slow.
I tried to use below code:
curl -H "Authorization: Session fdfdfdf-40c1-439c-8c9b-223fd0baa574_23596289" https://api.clarizentb.com/v2.0/services/bulk/execute -d "{requests:[{url:'ExpenseSheet/23bje1sn7lxusbpkkhry9v3nr844',method: 'DELETE'},{url:'ExpenseSheet/23bje1sn7lxusbpkkhry9v3nr840',method: 'DELETE'},{url:'ExpenseSheet/23bje1sn7lxusbpkkhry9v3nr836',method: 'DELETE'}]}"
But, it does not seem to work:
{"responses":[{"statusCode":404,"body":{"errorCode":"FileNotFound","message":"File not found: ExpenseSheet/23bje1sn7lxusbpkkhry9v3nr844.","referenceId":"1qHZGKg
BR41Qsl0kiwcMeQ"},"headers":[]}]}

Mattias Hallberg Answered

Please sign in to leave a comment.

2 comments

1
Avatar

Hi Mattias,

I believe the reason is your internal URLs are incorrect.

They should take the form of 'data/objects/ExpenseSheet/<id>'.

Hope this helps,

Ophir 

Ophir Kenig 1 vote
Comment actions Permalink
0
Avatar

Thanks Ophir, that did the trick!

 

I got below to work.

curl -H "Authorization: Session XXXXXX-4893-4358-bfea-YYYYYYYY_23596289" https://api.clarizentb.com/v2.0/services/bulk/execute -d "{requests:[{url:'data/objects/ExpenseSheet/21pits5517q6usfkfl3xx85ip460',method: 'DELETE'},{url:'data/objects/ExpenseSheet/21pits5517q6usfkfl3xx85ip480',method: 'DELETE'},{url:'data/objects/ExpenseSheet/21pits5517q6usfkfl3xx85ip512',method: 'DELETE'}]}"

 

Next is to come up with a way of creating such batch script instructions.

Mattias Hallberg 0 votes
Comment actions Permalink