Skip to content

Upload resources to the Open Government Registry using CURL

Rabia Sajjad edited this page Jun 30, 2021 · 1 revision

Use CURL to create a dataset through package_create API endpoint. This call returns a JSON response with the package_id for the dataset.

Once a dataset is created, you can add a new resource to the dataset using resource_create API endpoint. This call returns a JSON response with the id for the resource. You can create a resource with a CSV to be uploaded to the Cloud Storage by using the --form [email protected] field. CURL automatically sends a multipart-form-data heading when you use the --form option. You can also use the resource_patch API endpoint to update any fields in an existing resource.

Below are a few examples:

  1. Create a new resource for the dataset and upload a file to it using CURL
curl -H"Authorization: your-api-key" "https://registry.open.canada.ca/api/action/resource_create" --form package_id=UUID-of-the-dataset --form name_translated-en=resource-name-english --form name_translated-fr=resource-name-french --form language=en,fr --form resource_type=dataset --form format=CSV --form [email protected]
  1. Update an existing resource in a dataset and replace the URL with a file upload
curl -H"Authorization: your-api-key" "https://registry.open.canada.ca/api/action/resource_patch" --form id=UUID-of-the-resource --form [email protected]
  1. Update an existing resource in a dataset by replacing an uploaded file with a URL to the resource
curl -H"Authorization: your-api-key" "https://registry.open.canada.ca/api/action/resource_patch" --form id=UUID-of-the-resource --form url=http://example.com --form clear_upload=true
Clone this wiki locally