Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the Azure Mobile Service API feature

An API feature has been added to WAMS where I can define custom scripts. This seems to deprecate the previous practice of creating a script table. However, I couldn't find any description about how I can use it.

Which clients make this feature accessible? Can it be used from iOS or Javascript?

enter image description here

like image 586
allprog Avatar asked Jun 12 '13 23:06

allprog


People also ask

How do I use API in Azure?

Navigate to your API Management service in the Azure portal and select APIs from the menu. From the left menu, select + Add API. Select HTTP from the list. Enter the backend Web service URL (for example, https://httpbin.org ) and other settings for the API.

What is the main purpose of using the Azure Mobile App?

Azure Mobile Apps (also known as the Microsoft Data sync Framework) gives enterprise developers and system integrators a mobile-application development platform that's highly scalable and globally available.

How do I make Azure Mobile App using Azure?

Step 1: Log in to the Azure portal and create a new Azure mobile app backend. Step 2: Configure the mobile app backend. Step 3: Define a table controller. Step 4: Create the Data Transfer Object (DTO) class.


2 Answers

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);
}];
like image 58
carlosfigueira Avatar answered Sep 20 '22 16:09

carlosfigueira


this might help: What’s new in Windows Azure Mobile Service : Api Script

like image 29
JuneT Avatar answered Sep 21 '22 16:09

JuneT