And a couple more posts on this topic: http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/14/custom-apis-in-azure-mobile-services.aspx (server side) and http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/19/custom-api-in-azure-mobile-services-client-sdks.aspx (client side).
Also, since you tagged your question with ios, here's the code you'd use to call the API using an instance of the MSClient
class:
If your API only deals with (receives / returns) JSON data:
MSClient *client = [MSClient clientWithApplicationURLString:@"https://your-service.azure-mobile.net"
applicationKey:@"your-application-key"];
[client invokeApi:@"calculator/add"
body:nil
HTTPMethod:@"GET"
parameters:@{@"x":@7, @"y":@8} // sent as query-string parameters
headers:nil
completion:^(id result, NSURLResponse *response, NSError *error) {
NSLog(@"Result: %@", result);
}];
Or with a request body (POST):
[client invokeApi:@"calculator/sub"
body:@{@"x":@7, @"y":@8} // serialized as JSON in the request body
HTTPMethod:@"POST"
parameters:nil
headers:nil
completion:^(id result, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"Result: %@", result);
}];
If your API deals with non-JSON data, you can use the other selector which takes / returns a NSData
object:
NSData *image = [self loadImageFromSomePlace];
[client invokeApi:@"processImage"
data:image
HTTPMethod:@"POST"
parameters:nil
headers:nil
completion:^(NSData *result, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"Result: %@", result);
}];