POST request to locally hosted GraphHopper instance

Hi there,

I’m currently trying to solve TSPs using the open source routing engine, I am able to send a GET request to http://localhost:8989 for smaller problems, however, I want to eventually increase the size of my problems to include ~5000-10,000 vertices, which isn’t possible using this method as the URL is much too long.

I’ve tried looking up ways of sending a POST request, with the required vertices sent in JSON format, but I’ve found some conflicting results, as the documentation says it is possible to send POST requests while some forum posts I have found state otherwise.

Is it possible to send a HTTP POST request to the a local instance of GraphHopper? I’ve made some attempts to do so but I keep getting 400 and 405 response codes. If it is possible, any additional information you have about how to do so would be greatly appreciated!

Rob.

In the master you can use it already: https://github.com/graphhopper/graphhopper/pull/1762

Thank you for the quick reply! I was using the 0.13 branch, I’ve tried switching to the master branch but when I try and run the program from intelliJ I get this error:

java.lang.IllegalArgumentException: If no graph.location is provided you need to specify an OSM file.

Any ideas where I’m going wrong?

You might have the issue discussed in https://github.com/graphhopper/graphhopper/issues/1897 .

1 Like

I have updated to the master branch, I am still struggling with sending the POST request though, the only example of a POST request I can find is in the RouteResourceTest file and I am unsure of whether I can replicate this method outside of the test. Are there any other examples of how to send a POST request?

This should work:

curl -X POST -H "Content-Type: application/json" "http://localhost:8989/route" -d '{"elevation":false,"points":[[-0.087891,51.534377],[-0.090637,51.467697]],"vehicle":"car"}'
1 Like

Hi, thanks for the reply, I have now got the POST request working but have one final question, is it possible to return a map/graph of a tour from a POST sent through curl?

If not any advice as to how I could produce a visualisation for large TSPs without sending a POST?

Powered by Discourse