2015-09-30 44 views
2

我正在使用運行2.4版API AFAIK的demo.ckan.org進行一些測試。一切運作良好(組織和數據集創建),除了資源創建。 resource_create方法總是返回一個500錯誤。無法通過API在demo.ckan.org中創建資源(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> 
+0

很難說沒有訪問日誌的問題是什麼。另一種方法是使用package_show,向資源列表中添加一個新的資源字典,然後調用package_update。 – Ross

+0

酷,這將是一個很好的解決方法。可悲的是,對於我來說resource_create方法是有效的。 – frb

+1

我已經要求從服務器(在IRC上)的日誌,希望他們會對這個問題有所瞭解。這顯然是一個問題,而不是你做錯的事情,因爲我設法很容易地複製它。 – Ross

回答

1

這似乎是一個文檔(和代碼)錯誤。

儘管格式在文檔中標記爲可選,但代碼要求它存在(如果不是,則不幸會崩潰)。

我創建了一個在門票https://github.com/ckan/ckan/issues/2665

作爲一項臨時措施,直到這個是固定的,你可以在JSON指定「格式」發送(可以爲空)。

+0

它的作品,非常感謝!現在的問題是另一個:http://stackoverflow.com/questions/32881002/no-view-created-for-a-resource-at-demo-ckan-org – frb

相關問題