bing-maps

Can't get location from Bing Map API


I'm using Bing Map API to get latitude and longitude from address

https://dev.virtualearth.net/REST/v1/Locations?q=100+Somerset+St+New+Brunswick+NJ+08901&key={BingKey}

Got "authenticationResultCode":"ValidCredentials" latitude and longitude as 40.486216,-74.451819. But, when I use the same Bing MAP API key to get my Location detail from the lat and long, I get

https://dev.virtualearth.net/REST/v1/locationrecog/40.486216,-74.451819?key={BingKey}&output=json

Getting InvalidCredentials

{"authenticationResultCode":"InvalidCredentials","brandLogoUri":"https:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png","copyright":"Copyright © 2024 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","errorDetails":["Access was denied. You may have entered your credentials incorrectly, or you might not have access to the requested resource or operation."],"resourceSets":[],"statusCode":401,"statusDescription":"Unauthorized","traceId":"74c389b15e4e447ba1baf0089141d813|BN00006C5D|0.0.0.1"}

What wrong am I doing here. Any help please.


Solution

  • I tried the query you provided and it worked fine with my key. Double check the key in your URL, very easy to forget a character when copy/pasting (that's got me many times over the years).