Posting Traccar data to other server not working

kushal7 years ago

Hello Team,

First of thanks for such a great software.
I want to post data from traccar to my own database.
for this reason i am using forward.url , i am able to hit given url but not able to get data posted by traccar.
Below are changes done in traccar.xml.

<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://localhost:8081/gps/positions.php?id={uniqueId}&amp;code=0x0000&amp;gprmc={gprmc}</entry>

<entry key='event.enable'>true</entry>
<entry key='event.forward.header'> Content-Type: application/json; charset=utf-8 </entry>

at server side i have done below code which accepts json request and writes to a file.

<?php
  $log_dir = 'C:\xampp\htdocs\gps\tmp\test.txt';

#Get JSON as a string
$json_str = file_get_contents('php://input');


  $fp=fopen( $log_dir, "a" );
  fputs($fp, "jsonobj:".$json_str."\r\n");

  fclose($fp);
?>

But i am getting blank request.
can you please let me know where i am getting wrong.

Anton Tananaev7 years ago

Well, for event forwarding you haven't provided any URL, so it won't work.

As for position forwarding, it doesn't include any body. As you can see, all data is in query parameters.

kushal7 years ago

Thanks Anton,
Now i am able to receive position logs.
But i am not receiving logs for devices which are not registered in traccar.

I have installed traccar client app on my android phone , when i am starting service its showing send failed as that device is not registered in traccar web.

is it important to register device in traccar?

Anton Tananaev7 years ago

It is necessary, but there is an option to register devices automatically.

kushal7 years ago

can you please let me know , how can i register devices automatically.

Anton Tananaev7 years ago

Please read documentation before asking questions:

https://www.traccar.org/configuration-file/

kushal7 years ago

Thanks for sharing document link . i have found solution thanks.