An address with "#" causes exception RRS feed

  • Question

  • When I pass an address with '#', such as "125 Summer St #500, Boston, MA  02110, United States" to Bing Map Service "http://dev.virtualearth.net/REST/v1/Locations", an exception is thrown out saying "The remote server returned an error: (401) Unauthorized."

    When I remove '#', the address is geocoded correctly.

    Considering '#' is common in address, is there any way to pass an address with '#' to Bing Maps service?

    Wednesday, May 1, 2013 7:38 PM


  • The issue is occurring because the # is a special character used in URL's for linking to sections within a page. Because of this anything after the hash is being ignored, including the Bing Maps key which then results in a 401 authentication error. That said, the # information is not used in geocoding and only makes it more difficult to geocode your address. Removing it from your address would be the best choice. The # value isn't used that often when geocoding addresses. This is only the second time in the past 6 years I've had anyone run into this issue. A quick an dirty solution is to clean your address before querying it. A simply find and replce or a regular expression can be used to remove the hash value and trailing numbers.


    • Proposed as answer by Ricky_Brundritt Thursday, May 2, 2013 9:10 AM
    • Marked as answer by shi_hang_nk Friday, May 10, 2013 4:25 PM
    Thursday, May 2, 2013 9:10 AM