[ckan-dev] [ckan-use] API Question

David Read david.read at okfn.org
Thu Nov 10 11:24:18 UTC 2011


On 10 November 2011 11:12, DA ROS Jonathan <jdaros at sii.fr> wrote:
> Hi everybody,
>
>
>
> I'm trying to use API to delete my packages that i download with harvest
> plugin.

Perhaps @James can chime in here about deleting harvested datasets, as
I think it is different to normal packages/datasets?

> I know that it's impossible to delete them directly from the web GUI
> even for non harvest downloaded packages.

You can certainly delete packages from the Web interface (although
there may be issues with harvested packages). See
http://wiki.ckan.org/Managing_Data_Packages#How_do_I_Delete_a_package_.3F

> So, i was thinking to delete them
> with the API by writing the command on the web adress bar.

The web address bar is only good for simple GET requests. For deletion
you need to do a POST and that means using something designed for
that, such as 'curl' on the commandline.

> In fact i don't
> sucess to get access to the actions .. for instance writting :
>
> http://thedatahub.org/api/3/action/package_list -d '{}' i get the result :
>
> "Bad request - JSON Error: No request body data"

So this is because you're doing a GET from the browser.

> or another example : curl http://localhost:5000/api/rest/package -d
> '{"name":"test2", "title":"Changed Test package"}' -H "THE_KEY" via command
> line gives :
>
> "Acces denied" ( i'm root on ubuntuu and admin on ckan )

The header is missing the Authorization bit: -H "Authorization:THE_KEY"

(I assume you have replaced THE_KEY with your CKAN admin's api key)

David

>
>
> Anybody has an idea how i can do ? for sure something's wrong with the way i
> proceed...
>
>
> Thanks a lot for answer.
>
> John D.
>
> _______________________________________________
>
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
>




More information about the ckan-dev mailing list