I'm making a post from my Xamarin c# code to the PHP file that is on the server. My problem is that I don't receive the data I'm sending.
Client:
JObject oJsonObject = new JObject();
oJsonObject.Add("Id", "eee");
oJsonObject.Add("Referencia", 0);
oJsonObject.Add("Nom_Pieza", 23);
oJsonObject.Add("Cantidad", 4);
oJsonObject.Add("Precio", 2.6);
oJsonObject.Add("Importe", 1.1);
private string URL = "http://10.3.148.92/WebServiceXamarin/index.php";
//HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, URL);
var Content = new StringContent(oJsonObject.ToString(), Encoding.UTF8, "application/json");
HttpClient client = new HttpClient();
var response = await client.PostAsync(URL, Content);
var content = await response.Content.ReadAsStringAsync();
Server:
$Id = filter_input_array(INPUT_POST, "Id");
$Referencia = filter_input_array(INPUT_POST, "Referencia");
$Nom_Pieza = filter_input_array(INPUT_POST, "Nom_Pieza");
$Cantidad = filter_input_array(INPUT_POST, "Cantidad");
$Precio = filter_input_array(INPUT_POST, "Precio");
$Importe = filter_input_array(INPUT_POST, "Importe");
This is what I see when I run echo var_dump($_REQUEST);
and echo var_dump($_POST);
:
<pre class='xdebug-var-dump' dir='ltr'>
<small>C:\wamp64\www\WebServiceXamarin\index.php:27:</small>
<b>array</b> <i>(size=0)</i>
<i><font color='#888a85'>empty</font></i>
</pre>
What am I doing wrong? I can see that the code is running but I don't seem to be receiving any data in my PHP variables. Thank you