400: Bad Request for Virtual Earth Web Service

I’ve been getting quite a few messages about this “400: Bad Request” error people are seeing when trying to reference the Virtual Earth Web Service, more specifically when trying to fetch tokens so it’s worth posting a little something on how to fix it. Specifically, the error is, “There was an error downloading ‘http://staging.common.virtualearth.net/find-30/common.asmx’. The request failed with HTTP status 400: Bad Request.

The current documentation in the SDK shows a reference to https://staging.common.virtualearth.net/find-30/common.asmx; however, users aren’t getting the WSDL downloaded (I’ve had this problem myself). So, the solution is to change the reference to https://staging.common.virtualearth.net/find-30/common.asmx?wsdl.

In Visual Studio 2008, you’ll need to take a (odd) extra step. For some reason adding a Web Reference is different when you go to the “Add Service” advanced options than if you were to just Add Web Reference from Website menu. So, in Visual Studio 2008…

  1. Select the “Add Service Reference…” item from the Website menu.
  2. Click on the “Advanced…” button.
  3. Click on the “Add Web Reference…” button.
  4. Enter http://staging.common.virtualearth.net/find-30/common.asmx?wsdl for the URL and then hit the “Go” button.
  5. When prompted, enter your Virtual Earth Developer Account ID and password.
  6. Once WSDL has been downloaded, give the web reference a meaningful name like “TokenService” then click the “Add Reference” button.

This should fix your issues. We’ll be updating the SDK soon too.

CP

Join the conversation

9 comments
  1. cxfranco

    I did all steps but I have  same the problem why

    greetings.

  2. _Tim_

    Does not work for me!

    Microsoft Visual Studio 2008

    Version 9.0.30729.1 SP

    Microsoft .NET Framework

    Version 3.5 SP1

  3. Christopher Robin

    No joy for me either with the work around.

    VS2008, SL3.0

  4. Anonymous

    I'm getting the same "400" error, after applying all of the suggestions above.

    The URL I'm using is:

    staging.common.virtualearth.net/…/common.asmx

    and my IDE is VS 2005.

    Though I receive this error, and thus cannot name the Web reference nor click the [disabled] Add Reference button, I do see six methods listed in the 'description' multi-line text box below the URL field. They are GetClientToken, GetCountryRegionInfo, GetDataSourceInfo, GetEntityTypes, GetGreatCircleDistances, and GetVersionInfo.

    Also, I tried adding the above URL to the Trusted Sites along with this 2nd URL:

    common.virtualearth.net/…/common.asmx

    Still getting the error.

    Please help, thanks.

  5. Chris Pendleton

    Yes – this is fixed in VS 2010.

    CP

  6. Anonymous

    With VS NET 2010,can I add the Reference?

  7. Anonymous

    Just a note, that work around doesn't appear to work for me.

  8. Anonymous

    If you want to create a CS file using a WSDL utility, make sure you include your user name and password, otherwise you’ll get the same ‘400: Bad Request’ error:

    wsdl.exe /l:CS /n:StagingVEToken /u:USERNAME /p:PASSWORD /out:bin/StagingVEToken.cs https://staging.common.virtualearth.net/find-30/common.asmx?wsdl

Comments are closed.