c# how read JSON response to Bing Rest Service request. RRS feed

  • Question

  • I want to get the latitude and longitude from Bing Rest Services in a .net core razor page. I've made the call successfully, using the template from MS, but I'm having trouble referencing the proper location in the returned JSON structure. Below is how I expected it to work, but it doesn't compile. It says Resource doesn't have a definition for GeocodePoints

             string query = "1 Microsoft Way, Redmond, WA";
             Uri geocodeRequest = new Uri(string.Format("{0}&key={1}", query, BingMapKey));

             GetResponse(geocodeRequest, (x) =>
                Console.WriteLine(x.ResourceSets[0].Resources.Length + " result(s) found.");
                latitude = x.ResourceSets[0].Resources[0].GeocodePoints[0].Coordinates[0];
                longitude = x.ResourceSets[0].Resources[0].GeocodePoints[0].Coordinates[1];

    Tuesday, November 27, 2018 9:33 PM


  • Hi VanArsdale,

    You might try using a parser rather than the direct method you are attempting here.  You can do a web search for C# and GeoJSON and find a few samples like .   I have not used this library myself but I suspect you can look at the repo and see what it does to solve your issues.



    • Marked as answer by VanArsdale Wednesday, November 28, 2018 5:48 PM
    Wednesday, November 28, 2018 5:46 PM