一旦我的resource creation problem has been solved,我在demo.ckan.org上遇到了另一个问题。
创建资源后,我创建了一个数据存储区并插入了一些数据:
POST http://demo.ckan.org:80/api/3/action/resource_create HTTP/1.1
{"help": "http://demo.ckan.org/api/3/action/help_show?name=resource_create", "success": true, "result": {"cache_last_updated": null, "cache_url": null, "mimetype_inner": null, "hash": "", "description": "", "format": "", "url": "http://none", "created": "2015-10-01T06:18:25.471301", "state": "active", "webstore_last_updated": null, "webstore_url": null, "package_id": "51b379eb-a2a4-49d8-89b3-188dafdd0279", "last_modified": null, "mimetype": null, "url_type": null, "position": 0, "revision_id": "75c80743-66a8-49d2-a01f-ad67734386f5", "size": null, "id": "12eab044-7853-4907-9879-872550f1376b", "resource_type": null, "name": "room1_room"}}
POST http://demo.ckan.org:80/api/3/action/datastore_create HTTP/1.1
{"help": "http://demo.ckan.org/api/3/action/help_show?name=datastore_create", "success": true, "result": {"fields": [{"type": "int", "id": "recvTimeTs"}, {"type": "timestamp", "id": "recvTime"}, {"type": "text", "id": "entityId"}, {"type": "text", "id": "entityType"}, {"type": "text", "id": "attrName"}, {"type": "text", "id": "attrType"}, {"type": "json", "id": "attrValue"}, {"type": "json", "id": "attrMd"}], "method": "insert", "resource_id": "12eab044-7853-4907-9879-872550f1376b"}}
POST http://demo.ckan.org:80/api/3/action/datastore_upsert HTTP/1.1
{"help": "http://demo.ckan.org/api/3/action/help_show?name=datastore_upsert", "success": true, "result": {"records": [{"attrType": "centigrade", "recvTime": "2015-10-01T06:18:24.72Z", "recvTimeTs": "1443680304", "attrValue": "26.5", "entityType": "Room", "attrName": "temperature", "entityId": "Room1"}], "method": "insert", "resource_id": "12eab044-7853-4907-9879-872550f1376b"}}
数据存在,可以通过datastore_search
:
curl -s -S -H "Authorization: b4f6cd71-b592-49a3-bb85-9cd5a0f2eb68" "http://demo.ckan.org/api/3/action/datastore_search?resource_id=12eab044-7853-4907-9879-872550f1376b"
{"help": "http://demo.ckan.org/api/3/action/help_show?name=datastore_search", "success": true, "result": {"resource_id": "12eab044-7853-4907-9879-872550f1376b", "fields": [{"type": "int4", "id": "_id"}, {"type": "int4", "id": "recvTimeTs"}, {"type": "timestamp", "id": "recvTime"}, {"type": "text", "id": "entityId"}, {"type": "text", "id": "entityType"}, {"type": "text", "id": "attrName"}, {"type": "text", "id": "attrType"}, {"type": "json", "id": "attrValue"}, {"type": "json", "id": "attrMd"}], "records": [{"attrType": "centigrade", "recvTime": "2015-10-01T06:18:24.720000", "recvTimeTs": 1443680304, "attrMd": null, "attrValue": "26.5", "entityType": "Room", "attrName": "temperature", "entityId": "Room1", "_id": 1}], "_links": {"start": "/api/3/action/datastore_search?resource_id=12eab044-7853-4907-9879-872550f1376b", "next": "/api/3/action/datastore_search?offset=100&resource_id=12eab044-7853-4907-9879-872550f1376b"}, "total": 1}}
尽管如此,demo.ckan.org说:
尚未为此资源创建任何视图。
没有看到您期望的观点?点击此处获取更多信息。
以下是您可能看不到预期观点的一些原因:
- 尚未创建适合此资源的视图
- 网站管理员可能未启用相关的视图插件
- 如果视图需要DataStore,可能无法启用DataStore插件,或者数据可能未被推送到DataStore,或者DataStore尚未完成数据处理
我一直在使用2.2 API,并且不必创建任何视图。现在,似乎我必须使用2.4 API创建这样的视图。它是否正确,我必须使用http://docs.ckan.org/en/ckan-2.4.0/api/index.html#ckan.logic.action.create.resource_view_create
方法?或者它只是门户网站的问题?
答案 0 :(得分:3)
可能是演示服务器的设置方式,我建议您自己使用API调用来创建resource_view(除非您控制服务器并以不同方式配置它)是要走的路。
答案 1 :(得分:2)
不会像直接在数据存储区中创建的资源数据那样自动创建视图。创建由资源创建触发,假设存在一些数据,但您创建一个空资源并稍后向其添加数据。根据其他答案的建议,最佳途径是使用API。