[ckan-dev] Using CKAN's API via PHP (and private organisation search)

Aaron McGlinchy McGlinchyA at landcareresearch.co.nz
Thu Oct 2 00:43:12 UTC 2014


Hi, just an observation relating to issue 1718 that Ross referred too.

I've found that the general search box at the top tight of the page does not return private datasets, but if you click into an organisation, and search from the 'main' search box in the centre of the screen then private datasets you have rights to see do show up in the results.

Cheers
Aaron

Message: 3
Date: Mon, 29 Sep 2014 09:29:13 +0100
From: Ross Jones <ross at servercode.co.uk>
To: CKAN Development Discussions <ckan-dev at lists.okfn.org>
Subject: Re: [ckan-dev] Using CKAN's API via PHP.
Message-ID: <D0E8A200-6B3A-4D33-8343-4C842077EC89 at servercode.co.uk>
Content-Type: text/plain; charset="iso-8859-1"

This is clearly a bug of the this-is-a-sensible-request variety.

Could you file a ticket at https://github.com/ckan/ckan/issues/ ?
It *might* (and only might) be related to https://github.com/ckan/ckan/issues/1718

Ross.

On 29 Sep 2014, at 09:22, Henrik Aagaard J?rgensen <henrikaagaardjorgensen at gmail.com> wrote:

> Just saw the doc's and apparently it is not possible to access private datasets via the API with datastore_search_sql:
> "DataStore resource that belong to a private CKAN resource cannot be searched with this action."
>
> How unfortunate.
>
> Sorry for the trouble.
>
>
> 2014-09-29 10:19 GMT+02:00 Paolo Mainardi <paolo at twinbit.it>:
> As is written in the wiki: https://github.com/ckan/ckan/wiki/CKAN-API-Clients you can use those clients:
>
> - Ckan_client-PHP: https://github.com/jeffreybarke/Ckan_client-PHP
> - PHP CKAN client - from Silex. Uses Guzzle for the HTTP. Packaged using Composer; also on Github. Covers a number of action functions for reading/writing packages, resources, etc. Comes with tests (https://packagist.org/packages/silex/ckan_client)
>
> Thanks,
> P.
>
> On Mon, Sep 29, 2014 at 9:52 AM, Henrik Aagaard J?rgensen <henrikaagaardjorgensen at gmail.com> wrote:
> Hello everyone,
>
> I'm trying to use CKAN's API via PHP.
>
> I'm using cURL and are allowed if the dataset is not private. But when trying to access a private dataset I get access denied.
>
> CKAN is version 2.2 with datastore installed.
>
> Running this code fails with response from the CKAN API with "{'permissions': ['Not authorized to read resource.']}":
>
> -----
>
> $sql = 'SELECT * FROM "656eedf2-8648-442d-90fa-4500fc49eb4a"';
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "http://localhost/api/action/datastore_search_sql");
> curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('sql' => $sql)));
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($ch, CURLOPT_HTTPHEADER, Authorization'array(' => 'b5256727-2711-4ac5-9009-cfc155ec13a2'));
> $response = curl_exec($ch);
> curl_close($ch);
>
> var_dump(json_decode($response));
>
> -----
>
> When I use the code on public datasets it works. The API-key I'm using is the same as the user who created it, and I'm able to see it via the web interface.
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
>
>
> --
>
>
>
> Paolo Mainardi
> Twinbit Founder - CTO
>
> www:      twinbit.it
> mobile:   (+39) 3401678089
> skype:    paolo_mainardi
> linkedin: paolomainardi
> twitter:  @paolomainardi
> blog:     paolomainardi.com
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140929/12c20c21/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
https://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: https://lists.okfn.org/mailman/optionss/ckan-dev


------------------------------

End of ckan-dev Digest, Vol 47, Issue 23
****************************************

________________________________

Please consider the environment before printing this email
Warning: This electronic message together with any attachments is confidential. If you receive it in error: (i) you must not read, use, disclose, copy or retain it; (ii) please contact the sender immediately by reply email and then delete the emails.
The views expressed in this email may not be those of Landcare Research New Zealand Limited. http://www.landcareresearch.co.nz



More information about the ckan-dev mailing list