Search code examples
c#windows-runtimewindows-store-appsbing-maps

How to acquire Bing Maps SessionId for non-billable Bing Rest service using the WinRT API


I understand that using SessionId in Bing Maps Rest service calls are not billable after the first query per client, which is good. Regrettably it is not completly clear how to acquire this SessinID in the WinRT/Store App environment. The example on the MSDN site presents the following code in C# to acquire this ID:

Map.CredentialsProvider.GetCredentials((c) =>
{
    string sessionKey = c.ApplicationId;

    //Generate a request URL for the Bing Maps REST services.
    //Use the session key in the request as the Bing Maps key
});

The only issue I currently have is that the Map class nor its instance does not have this CredentialsProvider featuremethod. All I can get out from the Map instance is the Bing Map keys using its Credentials property, which returns the string that is added in the XAML declaration of the Map instance.

If someone could shed some light on how to acquire the relevant SessionID using Bing Maps Windows Store API that would be great! I'm not even sure if I need to generate this in my code or it is generated by the platform itself...Thank you!


Solution

  • Find the solution: call the GetSessionIDAsync on the Map instance after initialization!