[ckan-dev] adding a resource to a dataset via API
Sean Hammond
sean.hammond at okfn.org
Tue Aug 28 08:56:04 UTC 2012
On Mon, Aug 27, 2012 at 10:55:04AM +0100, Rufus Pollock wrote:
> On 25 August 2012 07:11, Jim Craner <jim at codeforamerica.org> wrote:
> > Hi,
> >
> > I'm a little stumped after reading the API docs here:
> > http://docs.ckan.org/en/latest/api-v2.html#model-api
> >
> > If I have an existing Dataset on our CKAN site (e.g., "Daily Water
> > Totals By Month") with multiple existing resources ("January.csv,"
> > "February.csv," etc.) and I want to add a new resource to it via API
> > ("March.csv"), what is the location? Do Datasets have hashes or other
> > IDs since I can change the name?
>
> Resources don't have a separate REST endpoint at present. To add a
> resource you get the Dataset object add to the list of resources and
> POST back.
If you the CKAN API v3, then there are resource_create, resource_update
etc. URLs that you can post to. The documentation is here:
http://docs.ckan.org/en/latest/apiv3.html
> On the second point: yes, datasets do have an ID (a uuid) which allows
> you to do things like change their names and which is completely
> permanent (unlikely the name which *can* change though you should try
> not to change it!)
Yes, may URLs of the v3 API accept an "id" field in the JSON that you
post to them, and this can either be the unique and permanent ID of the
dataset or its name (friendlier and also unique, but may change over
time), this also applies to other types of object, e.g. groups.
More information about the ckan-dev
mailing list