Can't avoid polygons - the rendered route sometimes doesn't avoid given polygons

POST https://api.openrouteservice.org/v2/directions/driving-car

body: {“coordinates”:[[20.506346,44.817654],[20.51733232812498,44.81754237897216]],“continue_straight”:false,“geometry_simplify”:false,“instructions”:true,“instructions_format”:“text”,“language”:“en”,“maneuvers”:true,“options”:{“avoid_polygons”:{“type”:“MultiPolygon”,“coordinates”:[[[[20.508921599233837,44.813770163259825],[20.509921599233834,44.813770163259825],[20.509921599233834,44.81277016325982],[20.508921599233837,44.81277016325982],[20.508921599233837,44.813770163259825]],[[20.51514432480322,44.81819458983359],[20.516144324803218,44.81819458983359],[20.516144324803218,44.81719458983358],[20.51514432480322,44.81719458983358],[20.51514432480322,44.81819458983359]],[[20.51389977982031,44.80828989868221],[20.514899779820308,44.80828989868221],[20.514899779820308,44.80728989868221],[20.51389977982031,44.80728989868221],[20.51389977982031,44.80828989868221]]]]}},“preference”:“recommended”,“roundabout_exits”:false,“suppress_warnings”:true,“units”:“m”,“geometry”:true}

Screenshot 2024-01-01 at 12.51.22
The rendered clock icons represent the polygon around the blue car - one of the 3 polygons passed in the request body. For some reason the API doesn’t avoid the polygon in 50% of the usecases

Hey,

the multipolygon you’re passing is misformatted. I assume you want to pass three polygons, but you’re passing one polygon with two inner rings.
You can fix this by encompassing each of your polygons separately with square brackets:

{
   "coordinates" : [[
         [
            [ 20.5089215992338, 44.8137701632598 ],
            [ 20.5099215992338, 44.8137701632598 ],
            [ 20.5099215992338, 44.8127701632598 ],
            [ 20.5089215992338, 44.8127701632598 ],
            [ 20.5089215992338, 44.8137701632598 ]
         ]],
         [[
            [ 20.5151443248032, 44.8181945898336 ],
            [ 20.5161443248032, 44.8181945898336 ],
            [ 20.5161443248032, 44.8171945898336 ],
            [ 20.5151443248032, 44.8171945898336 ],
            [ 20.5151443248032, 44.8181945898336 ]
         ]],
         [[
            [ 20.5138997798203, 44.8082898986822 ],
            [ 20.5148997798203, 44.8082898986822 ],
            [ 20.5148997798203, 44.8072898986822 ],
            [ 20.5138997798203, 44.8072898986822 ],
            [ 20.5138997798203, 44.8082898986822 ]
         ]]
   ],
   "type" : "MultiPolygon"
}

Best regards