frb
frb

Reputation: 3798

Create resource view in CKAN

I need to create a resource view in CKAN 2.5, but all the API documentation says is:

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

Nothing is said about the available view_type's nor how to create the required Json for the payload. As much, someone pointed me to http://docs.ckan.org/en/latest/maintaining/data-viewer.html, and I can figure out the views are recline_view, recline_grid_view, etc.

I've tried to create a recline_view view, but as said, the Json payload is necessary:

$ 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"

Upvotes: 3

Views: 984

Answers (1)

brew
brew

Reputation: 492

For curl, you'll need to use the -d (--data) option with the json string as its value. For example:

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"

Upvotes: 5

Related Questions