Ardjson: https://ardjson.codeplex.com This now includes the batch files for this blog.
Previous: Ardjson–Part 3 Command line Json: cURL.exe
As a follow up to the previous blog, the following lists some CRUD database commands using cURL.exe to manipulate a Windows Azure Mobile Service.
Note that each command is one line, although it might be display here on multiple lines.
The env.bat file used by all batch files:
@echo off@echo *@echo * Setting Azure Mobile Service URL and AppKey@echo * Edit in env.batset AzureMobileServiceURL=http://<Get this from Azure Portal>.azure-mobile.netset AppKey=<Get this from Azure Portal>@echo *@echo * Azure Mobile Service URL = %AzureMobileServiceURL%@echo * App Key = %AppKey%@echo *
[1.1] GET (Select/Read) all records in a table
curl -v -X GET -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% "%AzureMobileServiceURL%/tables/%MSTable%"
[1.2] GET Sort
curl -v -X GET -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% "%AzureMobileServiceURL%/tables/%MSTable%?$orderby=value"
Should able to get sort direction into this using ASC and DESC; ASC is the default. ???
[2] POST (Insert/Create) a new record
curl -v -X POST -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% -d "{\"sensor\":\"temperature\",\"date\":\"29-01-2015\",\"value\": 131}" %AzureMobileServiceURL%/tables/
[3.1] GET Filtered on a numeric value: EQ
curl -v -X GET -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% "%AzureMobileServiceURL%/tables/%MSTable%?$filter=(value%%20eq%%20131)"
[3.2] GET Filtered on a numeric value: GT
curl -v -X GET -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% "%AzureMobileServiceURL%/tables/%MSTable%?$filter=(value%%20gt%%2060)"
[3.3] GET Filtered on a string value: startswith
curl -v -X GET -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% "%AzureMobileServiceURL%/tables/%MSTable%?$filter=(startswith(sensor,'Temperature'))"
[3.4] GET Filtered on a boolean value
curl -v -X GET -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% "%AzureMobileServiceURL%/tables/%MSTable%?$filter=(complete+eq+false)"
A reminder that with Patch and Delete, you can't use filters. You must use the record id field.
[4.1] PATCH: Update a record
curl -v -X PATCH -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% -d "{\"completed\": true}" %AzureMobileServiceURL%/tables/%MSTable%/%RecordGUID%
[4.2] PATCH: Another update
curl -v -X PATCH -H Content-Type:application/json -H X-ZUMO-APPLICATION:%AppKey% -d "{\"sensor\":\"salinity\",\"complete\":\"true\",\"value\": 200}" %AzureMobileServiceURL%/tables/%RecordGUID%
DELETE a record
curl -v -X DELETE -H Content-Type:application/json -H X-ZUMO-APPLICATION:NtcMLPQtuAqWtvXOwrZVQtqHevNUnN27 %AzureMobileServiceURL%/tables/%MSTable%/%RecordGUID%
Next: Arduino and JSon