Skip to content

Instantly share code, notes, and snippets.

@eeeschwartz
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eeeschwartz/353eacdf6cb3199c14ad to your computer and use it in GitHub Desktop.
Save eeeschwartz/353eacdf6cb3199c14ad to your computer and use it in GitHub Desktop.
Create a CKAN resource and continually update it by upserting
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