I'm in a Xamarin project where I use a web service in PHP.
The problem is as follows, I send json to ws but when I receive it by POST, nothing arrives on it
C # code:
HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");
using (var client = new HttpClient()) {
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.PostAsync(uriActionString, content).Result;
if (response.StatusCode == HttpStatusCode.BadRequest) {
ret = false;
}
return ret;
}
obs: I already changed the
client.PostAsync(...).Result;
for
await client.PostAsync(...);
and without result.
By analyzing the application's performance, I can see both sides, and at first glance, it's "okay."
- comments:
Whengivingprint_rin$_POST,anemptyarrayisarriving.
Thevariable"json" that is in the StringContent is arriving correctly in the method.
The url is set correctly. When testing the same url and sending a variable by POST in postman, it is returning correctly as well.
As this is a more complex json, in this case I can not use the FormUrlEncodedContent object