What is the difference between the GET and POST route directions API?

Larissa Taylor 70 Reputation points
2025-01-16T16:56:48.9866667+00:00

When using the route directions API, the responses that are returned are very different when you do a GET request versus when you do POST request. In the application that I'm building, right now I think I need to do both request types to acheive the desired functionality; specifically I'm trying to display a truck route with a single waypoint visually on the map and textually as directions. The RouteInstructionControl (for the textual directions, https://github.com/Azure-Samples/azure-maps-services-ui/blob/master/docs/RouteInstructionControl.md) only seems to be able to proces GET requests, but there's additional information in the POST request that I also need. Obviously I don't want to have to make the call twice every time but with my current knowledge and understanding I think I have to.

My biggest question is WHY are the responses so different, what is the difference between these two API request types for seemingly the same information and when should I use what? My secondary question is do I really have to use both request types to accomplish my goal?

Maybe if I understood a little more about the differences I could figure out how to simplify here. Any additional information or documentation that anyone can point me to would be very much appreciated! Thank you in advance.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
778 questions
0 comments No comments
{count} votes

Accepted answer
  1. IoTGirl 3,296 Reputation points Microsoft Employee
    2025-01-20T18:21:02.0533333+00:00

    Hi Larissa,

    These are HTTP concepts that you can find with a web search which will give you sites like https://www.w3schools.com/tags/ref_httpmethods.asp but typically the restriction aligns with what you noticed. A GET request is limited to whatever length of URL you have available while POST allows you a huge payload, not limited to just the URL string length. Therefore, in a GET request can only provide a limited amount of detail while a POST request can provide far more context and return better, more informed and comprehensive, responses.

    You can just always do a POST request if you know all of the parameters and not do the GET request if you are looking to do only one call. You can see the example POST call for a single route here https://learn.microsoft.com/en-us/rest/api/maps/route/post-directions?view=rest-maps-2023-10-01-preview&tabs=HTTP#examples

    Sincerely,

    IoTGirl

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.