在 CKAN 中创建资源视图
Create resource view in CKAN
我需要在 CKAN 2.5 中创建一个资源视图,但是 API documentation 说的是:
ckan.logic.action.create.resource_view_create(context, data_dict)
Creates a new resource view.
Parameters:
resource_id (string) – id of the resource
title (string) – the title of the view
description (string) – a description of the view (optional)
view_type (string) – type of view
config (JSON string) – options necessary to recreate a view state (optional)
Returns:
the newly created resource view
Return type:
dictionary
没有提及可用的 view_type
以及如何为有效负载创建所需的 Json。同样,有人将我指向 http://docs.ckan.org/en/latest/maintaining/data-viewer.html,我可以弄清楚视图是 recline_view
、recline_grid_view
等
我试图创建一个 recline_view
视图,但如前所述,Json 有效负载是必需的:
$ curl -s -S -H "Authorization: my-api-key" "http://demo.ckan.org/api/3/action/resource_view_create?resource_id=eaf95b46-3a9f-4cbc-87cf-a6364e9581b1&title=view_test&view_type=recline_view"
"Bad request - JSON Error: No request body data"
对于 curl,您需要使用 -d
(--data
) 选项并将 json 字符串作为其值。例如:
curl -X POST http://localhost:5000/api/3/action/resource_view_create -d '{"resource_id":"my-resource-id", "view_type":"recline_grid_view", "title":"My recline grid"}' -H "Authorization:my-api-key"
我需要在 CKAN 2.5 中创建一个资源视图,但是 API documentation 说的是:
ckan.logic.action.create.resource_view_create(context, data_dict)
Creates a new resource view.
Parameters:
resource_id (string) – id of the resource
title (string) – the title of the view
description (string) – a description of the view (optional)
view_type (string) – type of view
config (JSON string) – options necessary to recreate a view state (optional)
Returns:
the newly created resource view
Return type:
dictionary
没有提及可用的 view_type
以及如何为有效负载创建所需的 Json。同样,有人将我指向 http://docs.ckan.org/en/latest/maintaining/data-viewer.html,我可以弄清楚视图是 recline_view
、recline_grid_view
等
我试图创建一个 recline_view
视图,但如前所述,Json 有效负载是必需的:
$ curl -s -S -H "Authorization: my-api-key" "http://demo.ckan.org/api/3/action/resource_view_create?resource_id=eaf95b46-3a9f-4cbc-87cf-a6364e9581b1&title=view_test&view_type=recline_view"
"Bad request - JSON Error: No request body data"
对于 curl,您需要使用 -d
(--data
) 选项并将 json 字符串作为其值。例如:
curl -X POST http://localhost:5000/api/3/action/resource_view_create -d '{"resource_id":"my-resource-id", "view_type":"recline_grid_view", "title":"My recline grid"}' -H "Authorization:my-api-key"