Google表单OAuth2Request-Xamarin表单中的错误请求

Google表单OAuth2Request-Xamarin表单中的错误请求,xamarin,oauth-2.0,google-sheets-api,Xamarin,Oauth 2.0,Google Sheets Api,因为GoogleSheetsAPI不支持Xamarin,所以我尝试使用Xamarin.Auth.OAuth2Request构建请求 以下代码表示请求的外观: Dictionary<string, string> value = new Dictionary<string, string> { { "range", "Arkusz1!A1:B1" },{ "values", "[Test,123]" }}; var request = new OAuth2Request(

因为GoogleSheetsAPI不支持Xamarin,所以我尝试使用
Xamarin.Auth.OAuth2Request
构建请求

以下代码表示请求的外观:

Dictionary<string, string> value = new Dictionary<string, string> { { "range", "Arkusz1!A1:B1" },{ "values", "[Test,123]" }};

var request = new OAuth2Request("POST", new Uri("https://sheets.googleapis.com/v4/spreadsheets/13FC0GZPbFbbOk8MW3N4fRvYq3lNKNZqsQdRsi0uVmgQ/values/Arkusz1!A1:B1:append?valueInputOption=RAW"), value, GoogleAccount);
var response = request.GetResponseAsync().Result;
Dictionary value=newdictionary{{“range”,“Arkusz1!A1:B1”},{“values”,“[Test,123]”};
var请求=新的OAuth2Request(“POST”),新的Uri(“https://sheets.googleapis.com/v4/spreadsheets/13FC0GZPbFbbOk8MW3N4fRvYq3lNKNZqsQdRsi0uVmgQ/values/Arkusz1!A1:B1:append?valueInputOption=RAW“),值,GoogleAccount);
var response=request.GetResponseAsync().Result;
GoogleAccount
是登录期间创建的帐户对象

不幸的是,我得到的回应是:“错误的请求””:

我认为问题出在OAuth2Request的第三个参数(IDictionary参数)中,但我不知道如何检查它。
我怎样才能得到更多的信息是什么导致了这种反应

我尝试了各种方法在OAuth2Request中传递参数,但它仍然不想合作最后,为了处理我的请求,我使用了HttpClient和HttpContent

以下代码表示我的最终工作算法:

//Initialize HttpClient instance
HttpClient client = new HttpClient();

//Dictionary whose contents correlates to body of request
Dictionary<string, List<string[]>> values = new Dictionary<string, List<string[]>>();
values.Add("values",new List<string[]>() { new string[] { "Test", "123" } });

//Serialize Dictionary to JSON
var json = JsonConvert.SerializeObject(values);

//Create StringContent which is based on JSON
var content = new StringContent(json, Encoding.UTF8, "application/json");

//Add authentication header. It can be taken from Account object
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",GoogleAccount.Properties["access_token"]);

//Call Post Request with our new content. Run it asynchronously or not.
var output = client.PostAsync(new Uri(@"https://sheets.googleapis.com/v4/spreadsheets/13FC0GZPbFbbOk8MW3N4fRvYq3lNKNZqsQdRsi0uVmgQ/values/Arkusz1!A1:B1:append?valueInputOption=RAW"), content).Result;

//初始化HttpClient实例
HttpClient=新的HttpClient();
//其内容与请求主体相关的词典
字典值=新字典();
Add(“values”,newlist(){newstring[]{“Test”,“123”});
//将字典序列化为JSON
var json=JsonConvert.SerializeObject(值);
//创建基于JSON的StringContent
var content=newstringcontent(json,Encoding.UTF8,“application/json”);
//添加身份验证标头。它可以从Account对象中获取
client.DefaultRequestHeaders.Authorization=新的AuthenticationHeaderValue(“承载者”,GoogleAccount.Properties[“访问令牌”);
//使用我们的新内容拨打Post请求。是否异步运行它。
var output=client.PostAsync(新Uri(@)https://sheets.googleapis.com/v4/spreadsheets/13FC0GZPbFbbOk8MW3N4fRvYq3lNKNZqsQdRsi0uVmgQ/values/Arkusz1!A1:B1:追加?valueInputOption=RAW“),内容)。结果;