Created
August 31, 2012 08:32
-
-
Save conceptdev/3550274 to your computer and use it in GitHub Desktop.
Azure Mobile Services example request in MonoTouch
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
// 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