After mapping HXL fields during export (#2518), user can send data from the Ushahidi platform to HDX via the HDX API.
When the CSV is generated with the HXL tags and the export_job is complete, we need to run an additional set of actions
- Create or update a dataset [Q: how do we decide if an update or create is used here?]
- Create or update the dataset's resources
TODO - connection to HDX:
steps
After the CSV + HXL file is uploaded to rackspace:
Creating a dataset
- POST https://data.humdata.org/api/action/package_create
{
"name": "test-dataset-romina",
"author": "Romina",
"maintainer": "romina-1223",
"organization": "ushahidi",
"private": true,
"owner_org": "ushahidi",
"title": "test-dataset-romina",
"dataset_source": "category lat lon data",
"data_update_frequency": "never",
"methodology": "other",
"tags": [{"name":"coordinates"}],
"license_id": "cc-by-sa",
"allow_no_resources": true
}
- the option
allow_no_resources to upload the files in a separate step
- HTTP Headers:
- X-CKAN-API-Key & Authorization both with your HDX Api key as value
- Content-Type: application/json
- Accept: application/json
Adding resources to a dataset:
- POST https://data.humdata.org/api/action/resource_create
{
"package_id": "xxxx-xxxx-xxxx-8e96bcceb658",
"url": "http://our-rackspace-files/hdx/countrylatlons.csv",
"resource_type": "csv",
"name": "package-csv-lat-lon"
}
- HTTP Headers:
- X-CKAN-API-Key & Authorization both with your HDX Api key as value
- Content-Type: application/json
- Accept: application/json
- Important: missing
name or resource type will result in a HTTP error 500 instead of a 422 and it won't provide any details about how/why it failed. The documentation does not list those two fields as required.
- Important we should really validate everything on our side as well to minimize potential issues with CKAN HDX
- How to get the values we will send:
package_id is returned in the package (dataset) creation. You can also get it with the "Get dataset' http request listed here.
url the url of the file in our CDN/File storage service.
See details of a package to obtain id or other data
https://data.humdata.org/api/action/package_show?id=test-dataset-romina
After mapping HXL fields during export (#2518), user can send data from the Ushahidi platform to HDX via the HDX API.
When the CSV is generated with the HXL tags and the export_job is complete, we need to run an additional set of actions
TODO - connection to HDX:
steps
After the CSV + HXL file is uploaded to rackspace:
Creating a dataset
{
"name": "test-dataset-romina",
"author": "Romina",
"maintainer": "romina-1223",
"organization": "ushahidi",
"private": true,
"owner_org": "ushahidi",
"title": "test-dataset-romina",
"dataset_source": "category lat lon data",
"data_update_frequency": "never",
"methodology": "other",
"tags": [{"name":"coordinates"}],
"license_id": "cc-by-sa",
"allow_no_resources": true
}
allow_no_resourcesto upload the files in a separate stepAdding resources to a dataset:
{
"package_id": "xxxx-xxxx-xxxx-8e96bcceb658",
"url": "http://our-rackspace-files/hdx/countrylatlons.csv",
"resource_type": "csv",
"name": "package-csv-lat-lon"
}
nameorresource typewill result in a HTTP error 500 instead of a 422 and it won't provide any details about how/why it failed. The documentation does not list those two fields as required.package_idis returned in the package (dataset) creation. You can also get it with the "Get dataset' http request listed here.urlthe url of the file in our CDN/File storage service.See details of a package to obtain id or other data
https://data.humdata.org/api/action/package_show?id=test-dataset-romina