[ckan-dev] Creating a Datastore resource via the API

Sara-Jayne Terp bodaceacat at yahoo.co.uk
Fri Mar 14 07:22:02 UTC 2014


Just noticed this question.  We found in CKAN2.0, we had to include the
owner_org in the keys when creating a resource, e.g.

{'name':resourcename,  'package_id':packagename,  'owner_org':ownername}

- there are examples of this in file ckan_calls.py in
https://github.com/bodacea/ckandump. 

HTH,


Sj.

Message: 2 Date: Fri, 14 Mar 2014 09:59:57 +1300 From: Jay Daley
<jay at controlfreak.net> To: CKAN Development Discussions
<ckan-dev at lists.okfn.org> Subject: Re: [ckan-dev] Creating a Datastore
resource via the API Message-ID:
<2CD12042-FB7B-4097-8FFD-02AB36C582A0 at controlfreak.net> Content-Type:
text/plain; charset=us-ascii A final follow up just to note that this
worked successfully on my own install of CKAN so it looks like the demo
site is stuffed somehow. Jay On 14/03/2014, at 9:08 am, Jay Daley
<jay at controlfreak.net> wrote:
>> On 13/03/2014, at 11:23 pm, Reinier Battenberg <reinier.battenberg at mountbatten.net> wrote:
>>
>>> did you also try a package_id like "jaystest" and then made it more complex 
>>> (capitals, spaces and finally a ' ) until it breaks?
>> I'm not sure what you mean?  I did have the package name wrong as it happens (used the org name not the dataset name) but I've since corrected and tried the following, all of which give the same error:
>>
>> 	{ "resource" : { "package_id" : "rbnz-c1-monetary-aggregates" } }
>> 	{ "resource" : { "package_id" : "rbnz-c1-monetary-aggregates" , "name" : "m3-y-on-y"} }
>> 	{ "resource" : { "package_id" : "rbnz-c1-monetary-aggregates" , "name" : "m3-y-on-y", "title" : "M3 Y on Y"} }
>>
>> I've also checked the package name through http://demo.ckan.org/api/3/action/package_list
>>
>> The full command, excluding my API key is:
>>
>> 	curl -X POST http://demo.ckan.org/api/3/action/datastore_create -H "Authorization: <my key>" -d @ckan-create.json
>>
>> where ckan-create.json is a file with just one of the lines above in it.
>>
>> cheers
>> Jay
>>
>>> On Thursday 13 March 2014 22:53:08 Jay Daley wrote:
>>>> Hi
>>>>
>>>> As I understand it from the documentation I should be able to create a
>>>> Datastore resource by specifying "resource" and a dictionary that has the
>>>> package_id and not specify a resource_id .  e.g.
>>>>
>>>> 	{ "resource" : { "package_id" : "Jay's Test" } }
>>>>
>>>> which I'm using against http://demo.ckan.org/api/3/action/datastore_create 
>>>> with a POST and my API key.
>>>>
>>>> However the error message I'm getting seems to contradict that:
>>>>
>>>> 	"success": false, "error": {"message": "Missig id, can not get Resource
>>>> object", "__type": "Validation Error"}
>>>>
>>>> Have I misunderstood the documentation?
>>>>
>>>> cheers
>>>> Jay
>>>> _______________________________________________
>>>> 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
>>> -- 
>>> rgds,
>>>
>>> Reinier Battenberg
>>> Director 
>>> Mountbatten Ltd.
>>> www.mountbatten.net
>>> tel: +256 758 801749
>>> twitter: @batje
>>> _______________________________________________
>>> 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
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 13 Mar 2014 19:37:04 -0400
> From: St?phane Guidoin <stephane at opennorth.ca>
> To: CKAN Development Discussions <ckan-dev at lists.okfn.org>
> Subject: Re: [ckan-dev] Pylons context object
> Message-ID:
> 	<CALoW1wCB2=A_WC6vrqNfpb_Hye2PKxg=8YMHJ2WRuo3y6e_YGw at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> If I remember well, it is possible to pass some variables to snippets
> without using function.
>
> Here is an example:
>     {% snippet "package/snippets/resources_list.html", pkg=pkg,
> resources=pkg.resources %}
>
> from
> https://github.com/ckan/ckan/blob/master/ckan/templates/package/read.html
>
>
> On Thu, Mar 13, 2014 at 4:32 PM, Pabitra Dash <pkdash_reena at hotmail.com>wrote:
>
>> Thanks Khalegh for letting me know this secret. It solved the problem for
>> me.
>>
>> Pabitra
>>
>>
>>
>> ------------------------------
>> From: khalegh at highwaythreesolutions.com
>> Date: Thu, 13 Mar 2014 13:12:09 -0700
>> To: ckan-dev at lists.okfn.org
>> Subject: Re: [ckan-dev] Pylons context object
>>
>>
>> Hi Pabitra,
>>
>> context object is not accessible in snippets and
>> package_metadata_fields.html is a snippet. I had the same problem and I
>> used helper functions instead.
>>
>> Best,
>> Khalegh
>> On Mar 13, 2014, at 12:20 PM, Pabitra Dash <pkdash_reena at hotmail.com>
>> wrote:
>>
>> Hi All,
>>
>> Any idea why the context object (c) may not be available in a template.
>> Jinja is throwing an error 'c' undefined. I am getting this error in my
>> extended template 'package_metadata_fields.html' where I am trying to
>> access the 'c.user' object.
>>
>> Thanks
>> Pabitra
>>
>>
>> _______________________________________________
>> 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-devUnsubscribe:
>> 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
>>
>>
>




More information about the ckan-dev mailing list