[ckan-dev] Cannot post json data to our own ckan server using the Ckan php client

Lloyd Harischandra ayubowan.ll at gmail.com
Thu Mar 6 02:54:42 UTC 2014


Thanks Hayden, Err I should have paid bit more attention to the error
message. I changed the name and used lower case letters and it solved the
issue. I am new to CKAN and I don't know how access the database or what
type of database is used in the server so only way for me to verify whether
there is a dataset or not is through the web interface. But I assume that
it wouldn't have created any datasets on my first try because name was
incorrect.

Cheers
Lloyd


On Thu, Mar 6, 2014 at 1:06 PM, Hayden Waring <haydenwaring at gmail.com>wrote:

> Hey Lloyd,
>
> Firstly for the 409 error you most likely have a dataset that has the name
> of test2 in the database.
>
> Secondly, the name that you are using is 'Test2' which is invalid. It must
> be purely lowercase. 'test2' would work provided that there is not already
> an entry in the database with the same name.
>
> Hayden,
>
>
> On Wed, Mar 5, 2014 at 5:06 PM, Lloyd Harischandra <ayubowan.ll at gmail.com>wrote:
>
>> Hi All,
>>
>> I am trying to use CKan php client to send following json data to one of
>> our own ckan servers.
>>
>> {"name":"Test2","title":"Test 2 by
>> Lloyd","url":"lloyd_2","notes":"notes_2","tags":
>>  [],"maintainer":"Lloyd","maintainer_email":"lloydharis at gmail.com
>> ","license_id":"ll_2","resources":[]}
>>
>> The code is:
>>
>> $ckan = new Ckan_client("http://my_url/api/");
>> $ckan->set_api_key('my_api_key');
>>  $data_array = array("name" => "Test2",
>> "title" => "Test 2 by Lloyd",
>>  "url" => "lloyd_2",
>> "notes" => "notes_2",
>> "tags" => array(),
>>  "maintainer" => "Lloyd",
>> "maintainer_email" => "my_email at xxxx.com",
>>  "license_id" => "ll_2",
>> "resources" => array());
>> $json_data = json_encode($data_array);
>>  $ckan->post_package_register($json_data);
>>
>> Then when I look at curl response, It says following:
>>
>> {"name": ["Url must be purely lowercase alphanumeric (ascii) characters
>> and these symbols: -
>>  _"]}
>>
>> And get 409 error - which is "Conflict (e.g. name already exists)"
>> according to Ckan_client.php class.
>>
>> But I cannot see any datasets on our server with that name when I login
>> using web interface.
>>
>> Does anyone know why I am getting this error?
>>
>>
>> Thanks
>> ~LLoyD~
>>
>> _______________________________________________
>> 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
>
>


-- 
~LLoyD~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140306/47c7fdc3/attachment-0003.html>


More information about the ckan-dev mailing list