Solved

Azure Custom API with Parameters

Posted on 2014-01-09
5
525 Views
Last Modified: 2014-11-12
As the title says.

Hi.  I'm trying to pass parameters to an Azure Mobile Servce Custom API.

Client I have..

Dim result = Await App.MobileService.InvokeApiAsync("apitest", System.Net.Http.HttpMethod.Post, New Dictionary(Of String, String) From {{"Param1", "Value1"}, {"CompleteAll", "true"}})
MessageBox.Show(result.ToString)

Open in new window



Server I have..

exports.post = function(request, response) 
{
   if (request.parameter.CompleteAll == "true")
    {
    response.send(statusCodes.OK, { message : 'True' });
    }
    else
    {
    response.send(statusCodes.OK, { message : 'False' });
    }
};

Open in new window


The call completes but always returns False as if the parameter is not being read.

Any ideas ?






But the parameter is never evaluated it seems ?
0
Comment
Question by:Dodsworth
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39768055
Are you it's a string : << == "true" >>
and not a boolean : << == true >>

exports.post = function(request, response) 
{
   if (request.parameter.CompleteAll)
    {
    response.send(statusCodes.OK, { message : 'True' });
    }
    else
    {
    response.send(statusCodes.OK, { message : 'False' });
    }
};

Open in new window

0
 
LVL 1

Author Comment

by:Dodsworth
ID: 39768312
The parameter is Dictionary(Of String, String)
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39768382
force it to check what you receive :
exports.post = function(request, response) 
{

    response.send(statusCodes.OK, { message : request.parameter.CompleteAll, typeOf:typeof request.parameter.CompleteAll });

};

Open in new window

0
 
LVL 1

Accepted Solution

by:
Dodsworth earned 0 total points
ID: 39768402
Sorted.

Request.Parameter is for use with CRUD scripts.

Request.Query for Custom APIs.

Obvious (not)!
0
 
LVL 1

Author Closing Comment

by:Dodsworth
ID: 39778762
Sorted.  Thanks for the code that helped me diagnose the problem.  I tries sharing some points but it didn't work :( I needed to ensure the answer marked was correct.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question