0

I have a weird behavior with Xamarin Refit in a PCL. When I send a Post request from my app, the server php script can only see the result in $_REQUEST, not in $_POST. (It's a simple php script, I don't use any Framework)

Here is the request :

[Post("/logUser.php")]
Task<UserResponse> LogUser(string email, string password);

And here is how I declare the Interface :

Func<HttpMessageHandler, ITFBApi> createClient = messageHandler =>
{
    var client = new HttpClient(messageHandler)
    {
        BaseAddress = new Uri(URLPaths.Api)
    };
    return RestService.For<ITFBApi>(client);
};

Am I doing something wrong ?

Thank you for the help,

GreuM
  • 155
  • 11

1 Answers1

0

So, I found an answer. I had to add the [Body] attribute to the request, and send an object :

[Post("/logUser.php")]
Task<UserResponse> LogUser([Body(BodySerializationMethod.UrlEncoded)] LogRequest request);

This way, the parameters are accesible in $_POST on the server side

GreuM
  • 155
  • 11