Requesting Matrix Calculation using POST method
wget
, there are two ways of sending a POST body: - POST body from file (Note: Make sure there is no dot character '.' at the end of file in the hex editor to avoid an error response from the server)
- POST body from string
The following example demonstrates a request of a matrix of routes for one start and two destinations points using a POST body from string and setting output filename with -O
switch.
wget "https://matrix.route.ls.hereapi.com/routing/7.2/calculatematrix.json
?apiKey={YOUR_API_KEY}
&mode=fastest;pedestrian;traffic:disabled"
--post-data="start0=52.43%2C13.4&destination0=52.5%2C13.43&destination1=52.5%2C13.46"
-O output.json
The following example demonstrates a request of a matrix of routes for one start and two destinations points using POST body from file and setting output filename with -O
switch.
wget "https://matrix.route.ls.hereapi.com/routing/7.2/calculatematrix.json
?apiKey={YOUR_API_KEY}
&mode=fastest;pedestrian;traffic:disabled"
--post-file=points.txt
-O output.json
Contents of file points.txt:
start0=52.43%2C13.4&destination0=52.5%2C13.43&destination1=52.5%2C13.46
Both examples result in the same response:
{
response: {
metaInfo: { /*content omitted*/ },
matrixEntry: [
{
startIndex: 0,
destinationIndex: 0,
summary: { costFactor: 9462 }
},
{
startIndex: 0,
destinationIndex: 1,
summary: { costFactor: 10600 }
}
]
}
}