无法通过API在demo.ckan.org中创建资源(500错误)

时间:2015-09-30 07:36:30

标签: ckan

我正在使用运行2.4版API AFAIK的demo.ckan.org进行一些测试。除资源创建外,一切运作良好(组织和数据集创建)。 resource_create方法始终返回500错误。

这是显示我想要创建资源的包的curl

$ curl -X GET "http://demo.ckan.org:80/api/3/action/package_show?id=f2c4125b-27c8-4e07-94d7-d6d0c0b65154" | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1228  100  1228    0     0   1384      0 --:--:-- --:--:-- --:--:--  1386
{
    "help": "http://demo.ckan.org/api/3/action/help_show?name=package_show",
    "result": {
        "author": null,
        "author_email": null,
        "creator_user_id": "b0a12b23-4cee-4d8c-993e-723421a0a296",
        "extras": [],
        "groups": [],
        "id": "f2c4125b-27c8-4e07-94d7-d6d0c0b65154",
        "isopen": false,
        "license_id": null,
        "license_title": null,
        "maintainer": null,
        "maintainer_email": null,
        "metadata_created": "2015-09-29T14:09:21.629953",
        "metadata_modified": "2015-09-29T14:09:21.669256",
        "name": "frb_org_test1_frb_pkg_test2",
        "notes": null,
        "num_resources": 0,
        "num_tags": 0,
        "organization": {
            "approval_status": "approved",
            "created": "2015-09-29T10:55:53.479724",
            "description": "",
            "id": "402f83c1-0070-4694-a1d9-f25b1d114631",
            "image_url": "",
            "is_organization": true,
            "name": "frb_org_test1",
            "revision_id": "26993878-9024-429a-b753-cc087b0ce382",
            "state": "active",
            "title": "",
            "type": "organization"
        },
        "owner_org": "402f83c1-0070-4694-a1d9-f25b1d114631",
        "private": false,
        "relationships_as_object": [],
        "relationships_as_subject": [],
        "resources": [],
        "revision_id": "47acfd70-8d26-4ebb-8cbd-6cababc627b1",
        "state": "active",
        "tags": [],
        "title": "frb_org_test1_frb_pkg_test2",
        "type": "dataset",
        "url": null,
        "version": null
    },
    "success": true
}

尝试创建资源时curl失败:

$ curl -X POST "http://demo.ckan.org:80/api/3/action/resource_create" -d '{ "name": "room1_room", "url": "none", "package_id": "f2c4125b-27c8-4e07-94d7-d6d0c0b65154" }' -H "Authorization: MY_API_KEY_IS_SECRET"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 [no address given] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at demo.ckan.org Port 80</address>
</body></html>

1 个答案:

答案 0 :(得分:2)

这似乎是文档(和代码)错误。

尽管格式在文档中被标记为可选,但代码要求它存在(并且如果不是,则会崩溃)。

我已在https://github.com/ckan/ckan/issues/2665

创建了一张票

作为一项临时措施,在此修复之前,您可以指定&#34;格式&#34;在您发送的JSON中(它可以为空)。