Search code examples
ckanopendata

cannot delete resource from CKAN data store


I am testing the datastore functionality on CKAN 2.3. I am running the basic tests on the CKAN DataStore page:

http://docs.ckan.org/en/ckan-2.3/maintaining/datastore.html#the-datastore-api

I am able to create, view and delete the dataset using these commands:

curl -X POST http://127.0.0.1:5000/api/3/action/datastore_create -H "Authorization: {YOUR-API-KEY}" -d '{"resource": {"package_id": "{PACKAGE-ID}"}, "fields": [ {"id": "a"}, {"id": "b"} ], "records": [ { "a": 1, "b": "xyz"}, {"a": 2, "b": "zzz"} ]}'

curl http://127.0.0.1:5000/api/3/action/datastore_search?resource_id={RESOURCE_ID}

curl -X POST http://127.0.0.1:5000/api/3/action/datastore_delete -H "Authorization: {YOUR-API-KEY}" -d '{"resource_id": "{RESOURCE-ID}"}'

However, if after creating the datastore resource after the first step, I delete using the UI, I can still view the datastore resource using step 2 and cannot delete it with step 3.

How would I clean this up?


Solution

  • I was finally able to successfully delete this. I had to use the "force:true" option in the command.

    curl -X POST http://127.0.0.1/api/3/action/datastore_delete -H "Authorization: myKey" -d '{"resource_id": "c1d0c269-f44b-4c78-a7a8-8c8fc1d18b27", "force":"True"}'

    Strange since if I try to delete without this option before deleting it via the UI, it works but if I delete with the UI, it makes the remaining DataStore resource read-only and then I need to use force. I am unable to find anywhere in documentation what makes a resource read-only.