Remove the squirrely braces from your query {
, }
. Your URL should look like this:
https://dev.virtualearth.net/REST/v1/Routes/Driving?wp.0=32.6115970189768,-103.459926710573&wp.1=31.95798907675224,-102.26350610450459&key=<YourBingMapsKey>
Be sure to replace <YourBingMapsKey>
with your Bing Maps key. Note this service calculates driving distances between points.
That said, I would highly recommend using Azure Maps instead. Bing Maps Enterprise platform announced its retirement a couple weeks ago and is directing customers to Azure Maps: https://azure.microsoft.com/en-us/blog/azure-maps-reimagining-location-services-with-cloud-and-ai-innovation/
To get driving distances between points Azure Maps has several services you can use:
- Route service (includes route instructions): https://learn.microsoft.com/en-us/rest/api/maps/route/get-route-directions?view=rest-maps-2023-06-01
- Batch route service (similar to above but get multiple routes in a single request): https://learn.microsoft.com/en-us/rest/api/maps/route/get-route-directions-batch?view=rest-maps-2023-06-01
- Route Matrix service (gets just distances, travel time, and traffic information): https://learn.microsoft.com/en-us/rest/api/maps/route/get-route-matrix?view=rest-maps-2023-06-01&tabs=HTTP
All of the above is for driving distances/travel times. If you only need straight line distances that are a couple of options:
- Use the Haversine formula in code, as doing this in code would not have any additional costs. It is a relatively simple calculation that is commonly used for straight line distances between coordinates. You can find code for this in a lot of different programming languages here: https://rosettacode.org/wiki/Haversine_formula
- There is the Great Circle Distance API in Azure Maps if you need to use a REST API: https://learn.microsoft.com/en-us/rest/api/maps/spatial/get-great-circle-distance?view=rest-maps-2023-06-01&tabs=HTTP