How to fix invalid Key RRS feed

  • Question

  • I am using the following to try to get elevation data:

    Private Async Sub Test(pts As List(Of Coordinate))
    	Dim Request As ElevationRequest = New ElevationRequest With
    		.BingMapsKey = <My Key>,
    		.Height = ElevationType.Ellipsoid,
    		.Points = pts
    	Dim Reply As Response = Await ServiceManager.GetResponseAsync(Request)
    Debug.WriteLine(Reply.ResourceSets IsNot Nothing)

    with this response:


    If I understand correctly a 401 status code means an invalid key.  However, I KNOW the key is valid (character by character checked - also validated from the Bing Maps Account page).  I can't find a resource within Microsoft to assist me with this problem.  Any suggestions?

    EDIT 1:

    I tried using a SessionKey as follows:

    Private Async Sub Test(pts As List(Of Coordinate))
    	Dim SessionKey As String = String.Empty
    								        SessionKey = c.ApplicationId
    		                                 End Sub)
    	Dim Request As ElevationRequest = New ElevationRequest With
    		.BingMapsKey = SessionKey,
    		.Height = ElevationType.Ellipsoid,
    		.Points = pts
    	Dim Reply As Response = Await ServiceManager.GetResponseAsync(Request)

    and, sadly, got the same result.

    • Edited by RogerSSB Monday, March 23, 2020 9:56 PM
    Friday, March 20, 2020 5:23 AM

All replies

  • Hi Roger,

    What has changed since this worked ?

    Two things come to mind:

    1. Please note that accounts do have limits. When you check your usage are you sure you still have transactions available on your account?

    2. Is there a leading space on your key string?



    Friday, March 20, 2020 7:11 AM
  • Yes, this query is a follow up to that one.  Nothing has changed, I just implemented the approach you gave in your reply and then got stuck on the invalid account message so posted again here.

    1. Ha!  I've made fewer than 10 elevation requests in total.  That can't be the issue.
    2. Below is my XAML code with almost all the characters deleted:
    Any ideas will be appreciated.

    • Edited by RogerSSB Friday, March 20, 2020 9:00 PM
    Friday, March 20, 2020 8:59 PM
  • Hi Roger,

    I am grasping here but what is the key type you created?  If it was working, I am not sure why it would stop.  Could you be hitting any other internet issues? Are you at the same location? Is there a firewall? It is puzzling for sure. Is there any other details with the response? A trace ID perhaps?



    Friday, March 20, 2020 10:44 PM
  • The Key is a string.  In the OP I showed how I entered the key in code and in my first response I showed how I created it in XAML.  Both are necessary, right?  One to use the map control and the other to use the BingMapsRESTToolkit, right.  And both are the same key, right?

    It was never working.  In my previous post what "worked" was the code fix you gave me.  The request itself as shown in the OP has never worked.

    I am at the same PC in my home/office with a direct connection to the router.  No firewall other than the one built into Windows 10.

    I don't get any error messages. Nada.  Only the output from the four Debug statements.  If I remove those statements, the code continues to run as if nothing has happened.

    Saturday, March 21, 2020 4:24 AM
  • I turned off the Windows firewall and ran the code.  Same problem.  So that's not where the issue is.
    Saturday, March 21, 2020 4:27 AM
  • Let's get the rest toolkit out of the equation for the moment. If you are using the Map control, you should make your REST calls with a V8 control session key as shown in our docs here:

    Monday, March 23, 2020 12:02 AM
  • I'm using the wpf control, not the V8.
    Monday, March 23, 2020 8:24 PM
  • Can you try this method from the WPF docs to call the REST API?

    Monday, March 23, 2020 9:41 PM
  • Before I saw this message, I tried the approach shown in EDIT 1  of the OP.  No luck.

    Now I'll try using the link you provided.

    Monday, March 23, 2020 9:58 PM
  • I implemented the application in that link and got a valid response back.  I used my own Bing Maps Key.

    Does that mean there is a problem with my code?  Its pretty hard to screw up:

    	Ceenter="<Lat, Long>"
    	CredentialsProvider="<My Key>"

    and the approach using the SessionKey as shown in Edit 1 of the OP.

    I have no idea how to proceed.

    Tuesday, March 24, 2020 12:38 AM
  • Is it possible there is some other problem which is masquerading as a Key problem?
    Tuesday, March 24, 2020 12:42 AM
  • Hi Roger,

    I believe this may be that your "Windows App" key won't work for REST calls and the basic Dev/Test key won't work for "Windows App".  This is because they are counted differently.

    Can you try the following?

    1. For the Application use a Windows App Key

    2. For the REST calls use a Web Key

    Note that you can make multiple keys in one Bing Maps account.



    Tuesday, March 24, 2020 2:46 PM
  • When I go to My Account > My Keys I get "Failed to get keys."  Yet when I go to the Reports page, it shows both my WPF-Control and my RESTElevations usage.

    Something is not right here and this public forum is not the appropriate place to try to resolve this issue.  Can we go off-line and work on this directly?  Or provide the best link for Account and/or technical support?


    Tuesday, March 24, 2020 10:26 PM
  • Hi Roger,

    There was a disruption in our key creation code this morning and it has been fixed.  Bing Maps Enterprise customers can create Microsoft Customer Service and Support cases through > Support > Bing Maps Enterprise Support but I suspect we have the issue identified here.  Application keys do not work for REST calls and REST keys do not work for Application calls.  My misunderstanding was based on this question being posted in the Web Control forum rather than the App forum.  The Web control does work with a REST key.



    Wednesday, March 25, 2020 8:27 PM