[ckan-dev] Accessing Data.gov's CKAN API through JavaScript

Andy Dufilie andy.dufilie at gmail.com
Sun Apr 20 04:06:16 UTC 2014


I spoke too soon. After implementing support for the legacy API I found
another problem:

Rest API (version 2):
List groups *doesn't work* - http://catalog.data.gov/api/2/rest/group
Show group *works* - http://catalog.data.gov/api/2/rest/group/law1129

Action API (version 3):
List groups *works* - http://catalog.data.gov/api/3/action/group_list
Show group *doesn't work* -
http://catalog.data.gov/api/3/action/group_show?id=law1129

There must be something wrong with the data.gov server. Technically I could
list groups with API v3 and show groups with API v2, but I'd rather not
implement that behavior.


On Sat, Apr 19, 2014 at 10:52 PM, Andy Dufilie <andy.dufilie at gmail.com>wrote:

> Thanks, it seems that the legacy API works fine.
>
>
> On Sat, Apr 19, 2014 at 11:13 AM, Alessio Dragoni <
> alessio.dragoni at gmail.com> wrote:
>
>> It might be because catalog.data.gov is using  different ckan version of
>> demo.ckan.org
>>
>> You can check it with http://catalog.data.gov/api/action/status_show
>>
>> You can use the legacy v1 api in case you need just informatin about
>> groups. Such api is present in all versions
>> On Apr 19, 2014 5:01 PM, "Andy Dufilie" <andy.dufilie at gmail.com> wrote:
>>
>>> Hi ckan-dev,
>>>
>>> I'm working on adding support for CKAN in Weave (oicweave.org).  I have
>>> it working with demo.ckan.org, but not catalog.data.gov.
>>> See this page for my tests, results shown at the end of this email:
>>> http://jsfiddle.net/2xFq7/9/
>>>
>>> I was getting the "Bad request - JSON Error: No request body data" error
>>> from demo.ckan.org when I had the wrong Content-Type earlier, so I
>>> thought setting the Content-Type may fix the problem with data.gov, but
>>> the CORS preflight request fails on data.gov when I specify any request
>>> headers.
>>>
>>> Does data.gov not want me to use the action API at all?  I noticed that
>>> it does not allow me to use the package_list action.
>>>
>>>
>>> Test results:
>>> {
>>>     "method": "GET",
>>>     "url": "
>>> http://demo.ckan.org/api/3/action/group_show?id=collectivites-locales&",
>>>     "status": "200 OK",
>>>     "success": true
>>> }
>>>
>>> {
>>>     "method": "POST",
>>>     "url": "http://demo.ckan.org/api/3/action/group_show",
>>>     "params": {
>>>         "id": "collectivites-locales"
>>>     },
>>>     "status": "200 OK",
>>>     "success": true
>>> }
>>>
>>> {
>>>     "method": "GET",
>>>     "url": "http://catalog.data.gov/api/3/action/group_show?id=law1129&
>>> ",
>>>     "status": "400 Bad Request",
>>>     "response": "Bad request - JSON Error: No request body data"
>>> }
>>>
>>> {
>>>     "method": "POST",
>>>     "url": "http://catalog.data.gov/api/3/action/group_show",
>>>     "params": {
>>>         "id": "law1129"
>>>     },
>>>     "status": "400 Bad Request",
>>>     "response": "Bad request - JSON Error: No request body data"
>>> }
>>>
>>> {
>>>     "method": "GET",
>>>     "url": "http://catalog.data.gov/api/3/action/tag_show?id=2010-data&
>>> ",
>>>     "status": "200 OK",
>>>     "success": true
>>> }
>>>
>>> {
>>>     "method": "POST",
>>>     "url": "http://catalog.data.gov/api/3/action/tag_show",
>>>     "params": {
>>>         "id": "2010-data"
>>>     },
>>>     "status": "409 Conflict",
>>>     "success": false,
>>>     "error": {
>>>         "__type": "Validation Error",
>>>         "id": "Missing value"
>>>     }
>>> }
>>>
>>> _______________________________________________
>>> 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/20140420/ec4289f4/attachment-0003.html>


More information about the ckan-dev mailing list