Using HTTP POST
The Directions API and Map Matching API both support access using the HTTP POST
method. HTTP POST
should be used for large requests, since both the Directions and Map Matching APIs have a size limit of approximately 8100 bytes on GET
request URLs. POST
requests are still subject to your account's request size limits.
If your request falls within the default limits (25 for Directions API requests using driving
, walking
, and cycling
profiles or 3 for request using the driving-traffic
profile; 100 for Map Matching API requests), a GET
request will work for you and you do not need to use POST
. If your account limits are larger than these defaults and you receive an HTTP 413
("Request entity too large") or HTTP 414
("Request URL too large") error when you make a GET
request to either API, then using POST
is a good option for you.
To submit a request using HTTP POST
, make the following changes to the request:
- The HTTP method must be
POST
. - The
Content-Type
of the request must beapplication/x-www-form-urlencoded
. - The coordinate list must be present in the request body as the
coordinates=
parameter. Do not put coordinates in the URL. - The
access_token
parameter must be part of thePOST
URL, not the body. All other parameters must be part of the request body.
A POST
request for the Map Matching API or the Directions API looks like this:
POST /{api_name}/{api_version}/mapbox/{profile}?access_token={your_access_token} HTTP/1.0
Content-Type: application/x-www-form-urlencoded
coordinates={lon1,lat1;lon2,lat2;...;lonN,latN}