Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#的Google Drive API请求不好,但邮递员的请求很好_C#_Http_Google Api - Fatal编程技术网

C#的Google Drive API请求不好,但邮递员的请求很好

C#的Google Drive API请求不好,但邮递员的请求很好,c#,http,google-api,C#,Http,Google Api,我使用了C#的请求代码,得到了一个错误的请求结果: public class GoogleDriveManager { private static readonly HttpClient Client = new HttpClient(); private const string Access = "ACCESS"; public GoogleDriveManager() { Clien

我使用了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;
        }
   }
公共类GoogleDriveManager
{
私有静态只读HttpClient客户端=新HttpClient();
private const string Access=“Access”;
公共谷歌驱动器管理器()
{
Client.DefaultRequestHeaders.Authorization=新的AuthenticationHeaderValue(“承载者”,访问);
}
公共异步任务GetFileAsync(字符串驱动ID)
{
变量url=
$"https://www.googleapis.com/drive/v3/files?driveId={driveId}&includeItemsFromAllDrives=true&corba=true&supportsAllDrives=true”;
var result=await Client.GetAsync(url);
返回结果;
}
}
但当我向邮递员提出同样的要求时,效果非常好:

得到

(授权承载令牌,令牌值与上述相同)

我在C方面做错了什么?

根据API支持的corpora值:

  • 使用者
  • 领域
  • 驱力
  • 所有驱动器
邮递员示例的corpora=drive,但C#示例的corpora=true

头撞在桌子上