[ckan-dev] A new ckan client library: ckanapi
Ian Ward
ian at excess.org
Sat Apr 27 15:31:18 UTC 2013
On Wed, Apr 24, 2013 at 2:53 PM, Heinrich Widmann <widmann at dkrz.de> wrote:
> Ok, then what should be used just to do some really basic things :
>
> 1. create a data set (just with default keys 'author' and 'maintainer')
> 2. update new meta data (key:value pairs) to the data set (as well
> extras-fields)
> 3. add the dataset to a group
>
> Likely we go in the total wrong direction - but I'm pretty sure, that there
> is an easy way or perform this simple upload actions with the CKAN APIs !?
>
> Maybe you can send us a python code, that performs at least the create and
> update step ?
> This would help a lot !
Some more testing revealed a problem with ckanapi and CKAN running
under Apache: Apache may not pass through the 'Authorization' header,
so I've switched to the 'X-CKAN-API-Key' header. If you were getting
NotAuthorized errors this fix might help you.
Here's a simple package_create with extras using ckanapi:
import ckanapi
dev = ckanapi.RemoteCKAN('http://my-dev-ckan', api_key='fd7bd...')
dev.action.package_create(
name='simple-test',
extras=[{'key': 'custom-field', 'value': 'extended data'}])
where the last line is the same as:
dev.call_action('package_create', dict(
name='simple-test',
extras=[{'key': 'custom-field', 'value': 'extended data'}]))
Ian
More information about the ckan-dev
mailing list