You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Overview

The purpose of this document is to describe a simple set of test cases for CKAN in order to determine viability for integration with Clowder.

Orientation

Familiarize yourself with the CKAN API by playing around with a few examples, like these: https://docs.ckan.org/en/ckan-1.7.4/api-tutorial.html

NOTE: You can use demo.ckan.org instead of test.ckan.org in the examples above.

Retrieve Your API Key

First, we'll need to add an API Key. To do this, you'll need to follow a few simple steps:

  1. Navigate to https://demo.ckan.org
  2. Register and/or login to CKAN
  3. At the top-right, click on the button containing Your Name
  4. At the bottom-left, your current API key should be listed

This should regenerate your existing API key, allowing you to interact with the CKAN API in an authorized fashion.

NOTE: This is currently causing an error on the CKAN Demo instance - Internal Server Error

Create a Dataset

Using the API key you just created above, create a dataset in CKAN:

$ curl https://demo.ckan.org/api/rest/dataset --header 'Content-Type: application/json' -d'{"name":"dataset-has-a-tail", "title":"OMG its a dataset"}' -H "Authorization:dd4dfb6e-2782-4465-ac20-40ed82ddd3ee" -vvv
*   Trying 104.24.114.210...
* TCP_NODELAY set
* Connected to demo.ckan.org (104.24.114.210) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: OU=Domain Control Validated; OU=PositiveSSL Multi-Domain; CN=sni113313.cloudflaressl.com
*  start date: Aug 11 00:00:00 2018 GMT
*  expire date: Feb 17 23:59:59 2019 GMT
*  subjectAltName: host "demo.ckan.org" matched cert's "*.ckan.org"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO ECC Domain Validation Secure Server CA 2
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f97b9005800)
> POST /api/rest/dataset HTTP/2
> Host: demo.ckan.org
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: application/json
> Authorization:dd4dfb6e-2782-4465-ac20-40ed82ddd3ee
> Content-Length: 58
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
< HTTP/2 201 
< date: Mon, 13 Aug 2018 18:00:49 GMT
< content-type: application/json;charset=utf-8
< set-cookie: __cfduid=d9a1e69c70ab278a0bf92a115a86c5d1f1534183248; expires=Tue, 13-Aug-19 18:00:48 GMT; path=/; domain=.ckan.org; HttpOnly
< cache-control: no-cache
< location: https://demo.ckan.org/api/rest/dataset/a09f9319-bf4c-48a0-8d98-a8d066d6636d
< pragma: no-cache
< vary: Accept-Encoding
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< server: cloudflare
< cf-ray: 449d1555af3055be-ORD
< 
* Connection #0 to host demo.ckan.org left intact
{"license_title": null, "maintainer": null, "private": false, "maintainer_email": null, "num_tags": 0, "id": "a09f9319-bf4c-48a0-8d98-a8d066d6636d", "metadata_created": "2018-08-13T18:00:48.853260", "relationships": [], "license": null, "metadata_modified": "2018-08-13T18:00:48.853275", "author": null, "author_email": null, "state": "active", "version": null, "creator_user_id": "28fb4558-3686-4b24-96d9-8d935190d962", "type": "dataset", "resources": [], "num_resources": 0, "tags": [], "groups": [], "license_id": null, "organization": null, "name": "dataset-has-a-tail", "isopen": false, "notes_rendered": "", "url": null, "ckan_url": "https://demo.ckan.org/dataset/dataset-has-a-tail", "notes": null, "owner_org": null, "ratings_average": null, "extras": {}, "ratings_count": 0, "title": "OMG its a dataset", "revision_id": "eaf48c90-b219-40a0-912a-00e7a5313697"}



Hooray! Your dataset has been created!

Updating or Modifying a Dataset

  • No labels