Last active
August 29, 2015 14:05
-
-
Save eeeschwartz/353eacdf6cb3199c14ad to your computer and use it in GitHub Desktop.
Create a CKAN resource and continually update it by upserting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v $CKAN_BASE_URL/api/action/resource_create \ | |
--form name="Complaints" \ | |
--form id="$resource_id" \ | |
--form package_id="$package_id" \ | |
--form format="csv" \ | |
--form url="http://104.131.23.252/datastore/dump/$resource_id" \ | |
-H "Authorization: $CKAN_API_KEY" | |
sleep 5 | |
fields='[{"id":"CaseNo","type":"text"},{"id":"CaseYr","type":"text"},{"id":"Address","type":"text"},{"id":"DateOpened","type":"date"},{"id":"CaseType","type":"text"},{"id":"Status","type":"text"},{"id":"StatusDate","type":"date"},{"id":"Closed","type":"bool"},{"id":"parcelId","type":"text"},{"id":"lat","type":"float"},{"id":"lng","type":"float"}]' | |
curl -v $CKAN_BASE_URL/api/action/datastore_create \ | |
-d '{"resource_id": "'$resource_id'","fields": '$fields', "primary_key":"CaseNo", "force":"true"}' \ | |
-H "Authorization: $CKAN_API_KEY" | |
curl -v $CKAN_BASE_URL/api/action/datastore_upsert \ | |
-d '{"resource_id": "'$resource_id'", | |
"records":'"`cat code-enforcement-complaints.json`"', | |
"force":"true" | |
}' \ | |
-H "Authorization: $CKAN_API_KEY" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment