Post data from another application to traccar API/application

mateng3 years ago

Hello!
...this does not work for me :-(

I configured traccar on my RaspberryPi using the mysql option.
Everything seems fine but posting all data to the database.
I tried several formats like this:

sudo wget http://localhost:5055/?id='0004A30B001A321C'&lat='47.6011867'&lon='11.4408763'×tamp='2016-11-05 16:55:21'&hdop='3'&altitude='747'&speed='0'

or {value} and "value"

The serve-log says:

2016-11-05 22:32:08  INFO: [E5C44E8E] connected
2016-11-05 22:32:08 DEBUG: [E5C44E8E: 5055 < 0:0:0:0:0:0:0:1] HEX: 474554202f3f69643d3030303441333042303031413332314320485454502f312e310d0a557365722d4167656e743a20576765742f312e313620286c696e75782d676e75656162696866290d0a4163636570743a202a2f2a0d0a486f73743a206c6f63616c686f73743a353035350d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a0d0a
2016-11-05 22:32:08 DEBUG: [E5C44E8E: 5055 > 0:0:0:0:0:0:0:1] HEX: 485454502f312e3120323030204f4b0d0a436f6e74656e742d4c656e6774683a20300d0a0d0a
2016-11-05 22:32:08  INFO: [E5C44E8E] disconnected
2016-11-05 22:32:09  INFO: [E5C44E8E] id: 0004A30B001A321C, time: 2016-11-05 22:32:08, lat: 0.00000, lon: 0.00000, speed: 0.0, course: 0.0

Here is an export from position table:

INSERT INTO 'positions' ('id', 'protocol', 'deviceid', 'servertime', 'devicetime', 'fixtime', 'valid', 'latitude', 'longitude', 'altitude', 'speed', 'course', 'address', 'attributes') VALUES
(31, 'osmand', 1, '2016-11-05 21:32:08', '2016-11-05 21:32:08', '2016-11-05 21:32:08', b'1', 0, 0, 0, 0, 0, NULL, '{"ip":"0:0:0:0:0:0:0:1","distance":0.0,"totalDistance":0.0}'),
(30, 'osmand', 1, '2016-11-05 21:31:20', '2016-11-05 21:31:20', '2016-11-05 21:31:20', b'1', 0, 0, 0, 0, 0, NULL, '{"ip":"0:0:0:0:0:0:0:1","distance":0.0,"totalDistance":0.0}'),
(29, 'osmand', 1, '2016-11-05 21:23:47', '2016-11-05 21:23:47', '2016-11-05 21:23:47', b'1', 0, 0, 0, 0, 0, NULL, '{"ip":"0:0:0:0:0:0:0:1","distance":0.0,"totalDistance":0.0}');

I have no clue what's going wrong.
mateng

Anton Tananaev3 years ago

Why do you have quotes in your URL? You should get rid of them.

If you decode your HEX, you will see what you are actually sending to the server:

GET /?id=0004A30B001A321C HTTP/1.1
User-Agent: Wget/1.16 (linux-gnueabihf)
Accept: */*
Host: localhost:5055
Connection: Keep-Alive

As you can see, it doesn't have any data except id.

mateng3 years ago

Hello Anton,
thank you very much for your response.

strange!
I deleted the Device an added it new.
Pasteing this in firefox:
http://172.30.1.166:5055/?id=0004A30B001A321C&lat=47.6011867&lon=11.4408763&timestamp=2016-11-05%2016:55:21&hdop=3&altitude=747&speed=0
Hurray!
Everything is working as expected!
Going back to wget .... same error as before.
Trying Firefox again... no
Looking at the mySQl table positions:
... wget failed at id 50 !
... Firefox did a good job at id 51
Looking at the mySQl table devices:
... positionid Sticks to id 50 !

No chance to get an Update in Frontend.
"Last Update " Timevalue is incrementing but positionid does not.

So there are two errors.
First: I have to debug my wget on raspberry.
Second:traccar should increment positionid in devices-table if there is new valid data.

thank you very much for your support.
mateng

mateng3 years ago
Anton Tananaev3 years ago

Nice, thanks for sharing the information.

tsilevych3 years ago

Greetings.

Got the problem with posting geodata too.

I`m using curl to do POST request:

curl -X POST http://demo.traccar.org:5055/?id=104641&lat=47.6011867&lon=11.4408763&timestamp=2016-11-10%12:55:21&hdop=1.0&altitude=747&speed=0

As a result I got the position of my device changed, but all parameters(like lat/lon, etc) is '0'.

What am I doing wrong?

Anton Tananaev3 years ago

The problem is exactly the same. Here is what you actually send:

POST /?id=104641 HTTP/1.1
Host: demo.traccar.org:5055
User-Agent: curl/7.47.0
Accept: */*
tsilevych3 years ago

Got it! Thank you for quick answer.