[ckan-dev] corupted JSON-string with API search

Scheel, Thomas thomas.scheel at fokus.fraunhofer.de
Mon Aug 27 08:57:09 UTC 2012


Hello Sean,
Actually I am using CKAN 1.7.1 and all the requests were send to the API 1 or 2 or whatever is chosen when requesting /api/search/dataset?sort=metadata_modified+desc&all_fields=1&limit with the corrupted string in the extra field and direct request to /api/rest/dataset/dataset1 with correct response 

Thanks a lot and would be great if you could evaluated this behavior.

Best / Viele Grüße,

Thomas Scheel

-----Ursprüngliche Nachricht-----
Von: ckan-dev-bounces at lists.okfn.org [mailto:ckan-dev-bounces at lists.okfn.org] Im Auftrag von Sean Hammond
Gesendet: Freitag, 24. August 2012 14:26
An: ckan-dev at lists.okfn.org
Betreff: Re: [ckan-dev] corupted JSON-string with API search

> the search URL for the call is 
> <IP>/api/search/dataset?sort=metadata_modified+desc&all_fields=1&limit
> =10
> the result is like this:
> ...
> extras": {
>     "geographical_granularity": "",
>     ...
>     "comments": "{u'date': u'Tue Aug 21 13:01:48 GMT 2012', u'comment': u'testing ckan', u'userId': u'11702'}",
>     ...
> }
> 
> but when calling the dataset directly  I get the correct resonse:
> ...
> "extras": {
>     "geographical_granularity": "",
>     ...
>     "comments": [
>         {
>             "date": "Tue Aug 21 13:01:48 GMT 2012",
>             "comment": "testing ckan",
>             "userId": "11702"
>         }
>     ],
>    ...
> ...

I think I'm getting a similar problem on CKAN master.  I created a dataset with an extra with key "comments" and a JSON list as value:

[{u'date': u'Tue Aug 21 13:01:48 GMT 2012', u'comment': u'testing ckan', u'userId': u'11702'}, {u'date': u'Wed Aug 22 13:01:48 GMT 2012', u'comment': u'testing ckan again', u'userId': u'11702'}]

When I visit http://127.0.0.1:5000/api/search/dataset?sort=metadata_modified+desc&all_fields=1&limit=10
I'm seeing my JSON value as a string the same as in your example.
(Actually when I visit the search URL in CKAN 1.7.1 I don't see my extra value at all, it seems that search didn't return extras in 1.7.1, are you actually using CKAN 1.8?).

I don't get a response like yours when I call the dataset directly, e.g. /api/rest/dataset/warandpeace or /api/action/package_show?id=warandpeace,
with /rest/dataset:

"extras": {
    "comments": "[{u'date': u'Tue Aug 21 13:01:48 GMT 2012', u'comment': u'testing ckan', u'userId': u'11702'}, {u'date': u'Wed Aug 22 13:01:48 GMT 2012', u'comment': u'testing ckan again', u'userId': u'11702'}]"
},

with package_show:

"extras": [
    {
        "state": "active",
        "value": "\"[{u'date': u'Tue Aug 21 13:01:48 GMT 2012', u'comment': u'testing ckan', u'userId': u'11702'}, {u'date': u'Wed Aug 22 13:01:48 GMT 2012', u'comment': u'testing ckan again', u'userId': u'11702'}]\"",
        "revision_timestamp": "2012-08-24T12:07:15.992601",
        "package_id": "94e3c804-f902-4316-abb1-246ddd1056a5",
        "key": "comments",
        "revision_id": "8511b279-a610-410b-b679-f29518073aa4",
        "id": "d85d6d5f-795c-4af7-9dfc-cb4eb6ee4bf7"
    }

What URL are you visiting when you call the dataset directly?

I've created a ticket for this issue but I think that's all I can do about it right now:

http://trac.ckan.org/ticket/2889

_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
http://lists.okfn.org/mailman/listinfo/ckan-dev




More information about the ckan-dev mailing list