Importing new geofence with Traccar API

fecondori2 years ago

Hi, I'm trying to create new geofences using the respective endpoint BUT I'm constantly getting 400 response code. Reviewing the documentation API there is a payload format with I tried but with no results (400 error code again). First I tried just formatting a JSON only with name, description , area, and attributes (because id is incremental and unknow and calendarId in nullable)

{
    "name": "Ruta 1", 
    "description": "Ruta 1", 
    "area": "POLYGON ((-70.1803777020084 -20.6594536675797,-70.1811776979915 -20.6594511324203,-70.1811296894221 -20.6443025910093,-70.1803297105779 -20.6443084089907,-70.180377702008
4 -20.6594536675797))", 
    "attributes": {"speedLimit": 100,color: "#000000"}
}

Then I tried with default values for each key, value

{
    "id": 0, 
    "name": "Ruta 1", 
    "description": "Ruta 1", 
    "area": "POLYGON ((-70.1803777020084 -20.6594536675797,-70.1811776979915 -20.6594511324203,-70.1811296894221 -20.6443025910093,-70.1803297105779 -20.6443084089907,-70.180377702008
4 -20.6594536675797))", 
    "calendarId": 0, 
    "attributes": {"speedLimit": 100,"color": "#000000"}
}

What is the correct format for the post body request (geofence endpoint)?
What if the geofence has no calendarId related?
In the traccar scheme geofence id is an incremental integer so, Why to create a new geofence the API requires an id in the payload?

Anton Tananaev2 years ago

What's the error message?

Anton Tananaev2 years ago

By the way, your JSON is invalid. It obviously has to be a valid JSON.

fecondori2 years ago

My bad, I was trying with an invalid JSON, by the way for my concern it was possible to create a new geofence without id and/or calendarId, based on the scheme just name and area columns are strictly necessary.

Anton Tananaev2 years ago

It is correct. Only name and area are the required parameters.