Closed robredpath closed 5 months ago
To add on to this: we did that in staging of IATI Registry
Hi @robredpath
I can confirm the data purge works on IATI.
As per the CKAN docs to delete a dataset the endpoint is package_delete
To purge the endpoint is dataset_purge
Also what username is trying to do the, they must be an admin on the publisher they are trying to purge the dataset on. Or else a superadmin
I created a script here which works for me on staging:
import requests from requests.auth import HTTPBasicAuth api_token = 'INSERT_OWN_TOKEN'
headers = { 'X-CKAN-API-Key': api_token, 'Content-Type': 'application/json', } username = "BASIC_AUTH_USERNAME" password = "BASIC_AUTH_PASSWORD" auth = HTTPBasicAuth(username, password)
IATI_STAGING_API_URL = 'https://staging.iatiregistry.org/api/action/' PACKAGE_ID = 'test-cormac-delete-me'
package = requests.get(IATI_STAGING_API_URL + f'package_show?id={PACKAGE_ID}', headers=headers, auth=auth)
print(package) package_delete = requests.post(IATI_STAGING_API_URL + 'package_delete', json={'id': PACKAGE_ID}, headers=headers, auth=auth ) print(package_delete.dict)
package_purge = requests.post(IATI_STAGING_API_URL + 'dataset_purge', json={'id': PACKAGE_ID}, headers=headers, auth=auth ) print(package_purge.dict)
@cormachallinanderilinx
Apologies, I was testing using the endpoint package_purge
. Purging works fine when using the endpoint dataset_purge
.
Thank you
Thanks for looking into this @cormachallinanderilinx; glad you got it sorted @PG-Momik
As per the CKAN docs to delete a dataset the endpoint is package_delete To purge the endpoint is dataset_purge
Now that's a trap for the unwary!
cc @praweshsth
YI have reported that they have tried to use
dataset_purge
but that the method doesn't exist in the Registry API. I believe they are using a sysadmin-level API key/token.