Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question

3 Answers

up vote 1 down vote accepted

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);
}];
share|improve this answer
 
Is there some latency between the published framework archive and the GitHub repository? github.com/WindowsAzure/azure-mobile-services The repo does not contain this addition yet. –  allprog Jun 15 at 21:12
 
It's usually in the repo a few days after the SDKs are published. I'd guess by early next week it should be there... –  carlosfigueira Jun 16 at 1:20

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

share|improve this answer
 
Great finding! Please add a few lines of explanation to your answer to make it more self contained and I'll immediately accept it. –  allprog Jun 13 at 5:40

i found this one help too:

http://www.windowsazure.com/en-us/develop/mobile/tutorials/create-pull-notifications-dotnet

basically you can access your custom API using this end-point format:

https://service_name.azure-mobile.net/api/api_name

put this on your script:

exports.get = function(request, response) {    
    response.send(200, "Hello World");
};

and set your API permission on GET to allow everyone, then you can use browser or fiddler to test your API by visiting the end-point:

https://service_name.azure-mobile.net/api/api_name

if you didn't change your permission, you have to put header code as below on your request:

GET https://service_name.azure-mobile.net/api/test HTTP/1.1
User-Agent: Fiddler
Content-type: application/json
X-ZUMO-APPLICATION: your-manage-key-here
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.