Last active
August 29, 2015 14:23
-
-
Save sleitner/e222a0499a8290f64db7 to your computer and use it in GitHub Desktop.
Interacting with datastore API
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
API_KEY='<INSERT YOUR API KEY>' | |
SITE_API='<CKAN WEBSITE:PORT>/api/3/action/' | |
RES_ID='<INSERT CREATED RESOURCE ID>' | |
#create | |
echo '----------------create' | |
curl -X POST ${SITE_API}/datastore_create -H "Authorization: ${API_KEY}" -d '{"force":"true", "resource_id":"'${RES_ID}'", "primary_key":["name"], "fields": [{"id":"name"},{"id":"tab", "type":"json"}],"records" : [ {"name": "datadict", "tab": [{"item1_int":1,"item2_txt":"xyz"}] } ]}'; echo ''; | |
curl -X POST ${SITE_API}/datastore_create -H "Authorization: ${API_KEY}" -d '{"force":"true", "resource_id":"'${RES_ID}'", "records" : [ {"name": "otherdata", "tab": [{"k1":1,"k2":2}] } ]}'; echo ''; | |
#show | |
echo '----------------show' | |
curl -X GET ${SITE_API}/datastore_search?resource_id=${RES_ID} -H "Authorization: ${API_KEY}"; echo ''; | |
#update | |
echo '----------------update' | |
curl -X POST ${SITE_API}/datastore_upsert -H "Authorization: ${API_KEY}" -d '{"force":"true", "resource_id":"'${RES_ID}'", "method":"upsert", "records" : [ {"name": "datadict", "tab": [{"item1_int":4444,"item2_txt":1111}] } ]}'; echo ''; | |
#show | |
echo '----------------show' | |
curl -X GET ${SITE_API}/datastore_search?resource_id=${RES_ID} -H "Authorization: ${API_KEY}"; echo ''; | |
#delete | |
echo '----------------delete otherdata' | |
curl -X POST ${SITE_API}/datastore_delete -H "Authorization: ${API_KEY}" -d '{ "force":"true", "resource_id":"'${RES_ID}'", "filters":{"name":"otherdata"} }'; echo ''; | |
#show | |
echo '----------------show' | |
curl -X GET ${SITE_API}/datastore_search?resource_id=${RES_ID} -H "Authorization: ${API_KEY}"; echo ''; | |
#delete | |
echo '----------------delete' | |
curl -X POST ${SITE_API}/datastore_delete -H "Authorization: ${API_KEY}" -d '{ "force":"true", "resource_id":"'${RES_ID}'", "filters":{} }'; echo ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output