Hi, i have a problem with send data to a service REST.
If i try from browser with “ionic serve” everything works correctly.
But if i try from emulator or device not working.
It seems that the type of data sent to the REST service is not the same.
This is the code: http://pastebin.com/sjBeb8kq
In REST service using data sent as:
$data = json_decode(file_get_contents('php://input'), true);
What would help us is if you could send us some logs from the php?
error_log(json_encode($data)); would show the object that you’re sending it.
And can you confirm that the call is being made to the API? Or does the API never receive the request
Hi, the API receive the call, but the data received is different…
print_r from emulator or device:
Array
(
[length] => 5
)
print_r from web (ionic serve):
Array
(
[0] => Array
(
[id_queue] => 1
[codice_prodotto] => 1
[magazzino] => 1
[scaffale] => 1
[posto] => 1
[action] => 1
[action_time] => 1438160009
)
[1] => Array
(
[id_queue] => 2
[codice_prodotto] => 2
[magazzino] => 1
[scaffale] => 1
[posto] => 1
[action] => 1
[action_time] => 1438160012
)
[2] => Array
(
[id_queue] => 3
[codice_prodotto] => 3
[magazzino] => 1
[scaffale] => 1
[posto] => 1
[action] => 1
[action_time] => 1438160024
)
[3] => Array
(
[id_queue] => 4
[codice_prodotto] => 4
[magazzino] => 1
[scaffale] => 1
[posto] => 1
[action] => 1
[action_time] => 1438160045
)
[4] => Array
(
[id_queue] => 5
[codice_prodotto] => 5
[magazzino] => 1
[scaffale] => 1
[posto] => 1
[action] => 1
[action_time] => 1438160067
)
)
I did a loop to the recordset and I created a custom object.
Now it works as web “ionic serve” and emulator “ionic emulate ios”, but if I try to test it on the device, do not perform any remote call.
Is there any type of restriction or permission?
It’s kind of bizarre for sure. Can you post a sample object of that? Without seeing the data I can only make guesses on what might be happening. If the calls were working previously they should still work.
Hi, now i tried to upload all on the remote server, and strangely seems to work well from the device.
Until recently I worked locally with MAMP.
I’ll keep you updated, even if it makes no sense …
1 Like