Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Azure Custom API with Parameters

Posted on 2014-01-09
5
Medium Priority
?
541 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 83

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 83

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Many of the companies I’ve worked with have embraced cloud solutions due to their desire to “get out of the datacenter business.” The ability to achieve better security and availability, and the speed with which they are able to deploy, is far grea…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…

824 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