没有为 demo.ckan.org 上的资源创建视图

2024-03-07

Once my 资源创建问题已解决 https://stackoverflow.com/questions/32860432/not-able-to-create-a-resource-in-demo-ckan-org-through-the-api-500-error,我在 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方法?或者只是门户网站的问题?


这很可能是演示服务器的设置方式,我建议使用 API 调用自己创建资源视图(除非您可以控制服务器并以不同的方式配置它)是可行的方法。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

没有为 demo.ckan.org 上的资源创建视图 的相关文章

随机推荐