我已经从Ubuntu 14.04软件包中安装了CKAN,现在我正在设置数据存储。
我按照这里的指示进行: http://docs.ckan.org/en/2.8/maintaining/datastore.html。
当我使用GET测试时,看起来还可以
roderico@roderico-VirtualBox:~$ curl -X GET "http://localhost/api/3/action/datastore_search?resource_id=_table_metadata"{"help": "http://192.168.1.3/api/3/action/help_show?name=datastore_search", "success": true, "result": {"include_total": true, "resource_id": "_table_metadata", "fields": [{"type": "int", "id": "_id"}, {"type": "name", "id": "name"}, {"type": "oid", "id": "oid"}, {"type": "name", "id": "alias_of"}], "records_format": "objects", "records": [], "_links": {"start": "/api/3/action/datastore_search?resource_id=_table_metadata", "next": "/api/3/action/datastore_search?offset=100&resource_id=_table_metadata"}, "total": 0}}
,但是当我执行POST时失败
roderico@roderico-VirtualBox:~$ curl -X POST http://localhost/api/3/action/datastore_create -H "Authorization: {1478356f-8f8f-4f16-a7c0-8bce46b6bece}" -d '{"resource": {"package_id": "{10aa3af0-a55c-4184-a13b-de8bb8047096}"}, "fields": [ {"id": "a"}, {"id": "b"} ], "records": [ { "a": 1, "b": "xyz"}, {"a": 2, "b": "zzz"} ]}'
此回复:
{"help": "http://192.168.1.3/api/3/action/help_show?name=datastore_create", "success": false, "error": {"message": "Access denied: <function datastore_create at 0x7f268d98baa0> requires an authenticated user", "__type": "Authorization Error"}}
它显示授权错误,所以我不知道可能是我使用了错误的详细信息。有想法吗?
我从配置文件中获得了api密钥,并从url中获得了包ID http://192.168.1.3/dataset/amigos/resource/10aa3af0-a55c-4184-a13b-de8bb8047096