Where did you get this configuration from?
Hi Anton,
I found an example in one forum post and tried to send custom data to my url
https://www.traccar.org/forums/topic/are-there-server-hooks/#post-1934
If I do not specify parameters in url it forward data but not device attributes and coordinates
The configuration parameters are completely different in that post.
Here is my config file
<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://192.168.89.239:3001/traccar/Data?id={uniqueId}</entry>
and the log
WARN: Position forwarding failed: 0 pending - HTTP code 404 - RuntimeException (PositionForwarderUrl:74 < *:67 < ...)
As you hopefully can see, your URL is returning error 404.
Hi Anton,
with this configuration
<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://192.168.89.239:3001/traccar/Data</entry>
I am able to get this data, but when I enter parameters like id, lat, lon, or any other I get:
error - The template variable 'lat' has no value - IllegalArgumentException (... < EventForwarderJson:41 < NotificationManager:141 < *:83 < *:155 < ConnectionManager:247 < ...)
{
event: {
id: 9495,
attributes: {},
deviceId: 5,
type: 'deviceOnline',
eventTime: '2024-04-22T07:21:25.966+00:00',
positionId: 0,
geofenceId: 0,
maintenanceId: 0
},
device: {
id: 5,
attributes: {},
groupId: 0,
calendarId: 0,
name: 'E-mak',
uniqueId: '864636061378788',
status: 'online',
lastUpdate: '2024-04-22T07:21:25.966+00:00',
positionId: 90419,
phone: null,
model: null,
contact: null,
category: null,
disabled: false,
expirationTime: null
}
}
This is not your configuration. The error is with event forwarding, which means you provided incorrect information.
This is config.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
<properties>
<entry key="config.default">./conf/default.xml</entry>
<entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://localhost/traccar?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
<entry key='database.user'>*****</entry>
<entry key='database.password'>*********</entry>
<entry key='server.port'>5055</entry>
<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://192.168.1.39:3000/traccar?id={uniqueId}&protocol={protocol}&name={name}&latitude={latitude}&longitude={longitude}&altitude={altitude}&speed={speed}&attributes={attributes}</entry>
</properties>
and the webhook is a simple js function to parse url and body. I would appreciate your suggestion.
I am trying to forward traccar gps data to my callback url from config file like below:
<entry key='event.forward.enable'>true</entry>--> <entry key='event.forward.url'>http://192.168.1.6/traccar?id={uniqueId}&deviceId={deviceId}&valid={valid}&fixTime={fixTime}&deviceTime={deviceTime}&protocol={protocol}&name={name}&latitude={latitude}&longitude={longitude}&altitude={altitude}&speed={speed}&attributes={attributes}</entry>
And I get the following error