【发布时间】:2019-08-28 17:53:34
【问题描述】:
我正在使用来自 C# 的此请求代码并获得错误的请求结果:
public class GoogleDriveManager
{
private static readonly HttpClient Client = new HttpClient();
private const string Access = "ACCESS";
public GoogleDriveManager()
{
Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Access);
}
public async Task<HttpResponseMessage> GetFilesAsync(string driveId)
{
var url =
$"https://www.googleapis.com/drive/v3/files?driveId={driveId}&includeItemsFromAllDrives=true&corpora=true&supportsAllDrives=true";
var result = await Client.GetAsync(url);
return result;
}
}
但是当我向 Postman 提出同样的请求时,效果很好:
(Authorization Bearer Token,token值同上)
我在 C# 方面做错了什么?
【问题讨论】:
标签: c# http google-api