我正在尝试向Google位置Api发送Http Get消息,该消息应该具有类似于以下内容的Json数据
https://maps.googleapis.com/maps/api/geocode/json?address=Los%20Angeles,CA=AIzaSyDABt 正如您所注意到的那样,响应以Json格式返回。我想给那个URL发出Http调用,并将Json内容保存在变量或字符串中。我的代码没有出现任何错误,但也没有返回任何内容。
public async System.Threading.Tasks.Task<ActionResult> GetRequest()
{
var client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("https://maps.googleapis.com/maps/api/geocode/json?address=Los%20Angeles,CA=AIzaSyDABt");
string data = response.Content.ToString();
return data;
}
我想使用HttpClient()或任何能够发送URL请求并将内容保存到字符串变量中的方法来发送Get请求。如果有建议,将不胜感激。再次说明,我的代码没有错误,但它没有返回任何内容。