Skip to content

Instantly share code, notes, and snippets.

@conceptdev
Created August 31, 2012 08:32
Show Gist options
  • Save conceptdev/3550274 to your computer and use it in GitHub Desktop.
Save conceptdev/3550274 to your computer and use it in GitHub Desktop.
Azure Mobile Services example request in MonoTouch
// credit for Objective-C version to http://chrisrisner.com/Windows-Azure-Mobile-Services-and-iOS
GetAllUrl = "https://taskyazure.azure-mobile.net/tables/TodoItem?$filter=(complete%20eq%20false)";
AddUrl = "https://taskyazure.azure-mobile.net/tables/TodoItem";
UpdateUrl = "https://taskyazure.azure-mobile.net/tables/TodoItem/"; // slash on purpose
string MobileServiceAppId = "xxxxxxxxxxxxxxxxxxxxxxxx"; // your application key
void LoadTodos()
{
WebClient client = new WebClient();
try {
// make it synchronous
client.Headers.Add (HttpRequestHeader.Accept, "application/json");
client.Headers.Add ("X-ZUMO-APPLICATION", Constants.MobileServiceAppId);
var response = client.DownloadData (Constants.GetAllUrl); // GET
// ...and wait...
var responseString = System.Text.Encoding.UTF8.GetString(response);
Console.WriteLine ("Json response => " + responseString);
//
// RETURNS [{"id":1,"text":"Port to iOS and Android","complete":false}]
//
} catch (System.Net.WebException e) {
Console.WriteLine ("X-ZUMO-APPLICATION failed" + e.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment