[ckan-dev] ckanapi

Stéphane Lapointe lapointes at ogsl.ca
Thu Mar 30 17:11:12 UTC 2017


Thank you for pointing this out.

I didn't set the package_id correctly. I choose "id" in place of "name", 
which are both UUID in my use case. My mistake. Sorry.

Thank you.


Le 2017-03-01 à 18:30, Ian Ward a écrit :
> If you're getting a server error check your server logs for the full traceback.
>
> ckanapi's RemoteCKAN class uses requests.post too, so there
> *shouldn't* be a difference between using ckanapi.RemoteCKAN and
> requests except for getting meaningful exceptions from ckanapi when
> something fails.
>
> On Wed, Mar 1, 2017 at 5:19 PM, Stéphane Lapointe<lapointes at ogsl.ca>  wrote:
>> Hi everybody,
>>
>> I wrote a script to upload resources to CKAN instance. Everything work fine
>> except for Excel files. I get a 'Servor Error' while accessing resource on
>> Web UI.
>>
>> This is in essence the code I execute without error.
>>
>> # resource_dict is set, including package_id and other attributes
>> resource_dict['upload'] = open('path_to_a_file', 'rb')
>> ckanremote.action.resource_update(**resource_dict)
>>
>> Again, this piece of code works for PDF, ZIP, etc. but not for XLS, XSLX
>>
>> I've activated DataStore and set up FileStorage.
>>
>> Strangely, when I do
>>
>> requests.post(url, data={"package_id": "id"}, headers={"X-CKAN-API-Key":
>> "my_api_key"}, files=[('upload', file('path_to_a_file'))])
>>
>> it works perfectly. So I have a solution for my problem, but I would like to
>> understand what I'm missing.
>>
>> Thank you.
>> _______________________________________________
>> 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

-- 

Stéphane Lapointe

*Analyste programmeur  |  Programmer Analyst*

https://ogsl.ca/images/visuel/Equipe/signatures/logos.png

*Observatoire global du Saint-Laurent  |  St. Lawrence Global Observatory*

310, allée des Ursulines

Rimouski Qc Canada  G5L 3A1

Téléphone  |  Telephone : 418.723.8372   poste | ext. 1195

Internet : http://ogsl.ca <http://ogsl.ca/>   | http://slgo.ca 
<http://slgo.ca/>

Suivez-nous sur | Follow Us : Facebook 
<https://www.facebook.com/pages/OGSL/140878112686019>  | Twitter 
<https://twitter.com/#%21/OGSL_SLGO>  | LinkedIn 
<http://www.linkedin.com/company/observatoire-global-du-saint-laurent---ogsl> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20170330/92d3f59d/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 27074 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20170330/92d3f59d/attachment-0003.png>


More information about the ckan-dev mailing list