Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Azure Custom API with Parameters

Posted on 2014-01-09
5
522 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
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…

861 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