none
What are correct Ajax headers for Bing API request? RRS feed

  • Question

  • What is the proper header syntax for a Bing API request with ajax? Right now I have this

    $http({
         method: 'POST',
         url: myurl,
         headers: {
                  'Authorization': 'Basic QiHPp4ct1m'
         }
    });

    But I'm getting a 401 error "The authorization type you provided is not supported. Only Basic and OAuth are supported."

    Friday, December 5, 2014 9:49 AM

Answers

  • The headers is not the issue. The issue is that you are making a cross domain post request which won't work. Older browsers don't support cross domain POST requests. Newer one's only support it if CORS is enabled in the service, which it isn't for the Bing Maps REST Services (CORS only became a W3C standard in January).

    To make a POST request to the Bing Maps REST Services you have to create a proxy service that makes the request from server side code. I have a blog post on how to do this coming out soon. you can find the code samples online here: https://code.msdn.microsoft.com/POST-requests-to-Bing-Maps-c056575a


    http://rbrundritt.wordpress.com

    Friday, December 5, 2014 1:35 PM