Calling Google Place APIs from ASPNet Core Web App code

Hi,

To call Google Place API, construct a URI string with example below, to call nearbysearch API

And then create a code similar to below to call the API, get the response and transform it to JSON format

                try
                {
                    HttpResponseMessage response = await client.GetAsync(sUri);
                    Console.WriteLine(sUri);
                    response.EnsureSuccessStatusCode();
                    string responseBody = await response.Content.ReadAsStringAsync();
                    Console.WriteLine(responseBody);
                    jResult = JsonConvert.DeserializeObject<JSONGoogleAPI>(responseBody);
                }
                catch (HttpRequestException e)
                {
                    Console.WriteLine(e.Message);
                }

Kindly leave a comment if you have any questions.

Cheers

Leave a comment