Link to home
Start Free TrialLog in
Avatar of Dodsworth
Dodsworth

asked on

Azure Custom API with Parameters

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 ?
Avatar of leakim971
leakim971
Flag of Guadeloupe image

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

Avatar of Dodsworth
Dodsworth

ASKER

The parameter is Dictionary(Of String, String)
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

ASKER CERTIFIED SOLUTION
Avatar of Dodsworth
Dodsworth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.