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?
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.
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.
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.
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);
}];
this might help: What’s new in Windows Azure Mobile Service : Api Script
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With