But we are sending a lat and lng in the input json. So why would further geocoding be required? We are currently sending the address to open street maps to get the geo coordinates.
This issue has been signalled by free users that add addresses on the map of the routeplanner website. If you import coordinates or use our API, indeed no geocoding is required.
If you use the API or import coordinates, and you get the same error, thatâs probably another issue. Weâd need more details to check that.
Here is my payload: {"locations":[{"address":"Landsbergerstr. MĂźnchen","lat":48.1399037,"lng":11.5345584},{"address":"Boosstr. 17, MĂźnchen, 81541","lat":48.124691999999996,"lng":11.579191521147884},{"address":"ZeppelinstraĂe 17, MĂźnchen, 81481","lat":48.2518594,"lng":11.622388597187761},{"address":"Zenettistr. MĂźnchen","lat":48.1226403,"lng":11.5593216}]}
I am getting a 409 response.
My request URL is https://api.routexl.com/tour and my request method is POST
Weâve split this into a seperate topic as it is another issue. Your 409 response is probably triggered because itâs only the locations value that needs to be json_encoded, not the payload as a whole. Check this example in Postman:
I am sending via params and not x-www-form-urlencoded⌠when I send that way I get a response.
Hello, my name is Renato, sorry I have the same problem, my question is if you managed to solve it, I donât know if you can write to my gmail renatosalinas334@gmail.com I would be very grateful
Hi - me too - getting the 409 ⌠how did you solve? thanks
For the 409 error the first thing to check is the locations parameter, of which only the value should be JSON encoded. See also: Testing API POST does not work
Hi @RouteXL - thanks for the response.
The bit that to me was non-obvious to me was that the data is encoded as application/x-www-form-urlencoded
and the flag for curl
is --data-urlencode
The below works just fine with postman
curl --location --request POST 'https://api.routexl.com/distances' \
--header 'Authorization: Basic foobarfoobarfoobarfoobarfoobar==' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'locations=[{"address":"The Hague, The Netherlands","lat":"52.05429","lng":"4.248618"},{"address":"The Hague, The Netherlands","lat":"52.076892","lng":"4.26975"},{"address":"Uden, The Netherlands","lat":"51.669946","lng":"5.61852"},{"address":"Sint-Oedenrode, The Netherlands","lat":"51.589548","lng":"5.432482"}]'
tour
endpoint also works just fine like this so I am all set now, thanks again
I had the same 409 error in React app which solved it this way,
const response = await fetch(https://api.routexl.com/tour
,{
method: âPOSTâ,
headers: {
âContent-Typeâ: âapplication/x-www-form-urlencodedâ,
âAuthorizationâ: "Basic " + btoa(âusername:passwordâ)
},
// the following code is in backticks
body: locations=${JSON.stringify(locations)}
});
response.text().then( (text)=>{
console.log(JSON.parse(text).route);
// do what you want with the route
})