Solved

Azure Custom API with Parameters

Posted on 2014-01-09
5
513 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
Comment Utility
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
Comment Utility
The parameter is Dictionary(Of String, String)
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
Comment Utility
Sorted.

Request.Parameter is for use with CRUD scripts.

Request.Query for Custom APIs.

Obvious (not)!
0
 
LVL 1

Author Closing Comment

by:Dodsworth
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article discusses how to create an extensible mechanism for linked drop downs.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now