更新提供错误的日历事件“指定的值不是有效的带引号的字符串" [英] Updating Calendar Event Giving Error "The specified value is not a valid quoted string"
问题描述
从今天开始,当我们尝试使用Google Calendar V3 API更新事件时,就会收到错误消息.
As of today we are getting an error when we try to update an event using Google Calendar V3 API.
这是我们的代码:
string certificateFile = getCertificateFile();
string certificatePassword = getCertificatePassword();
string serviceAccountEmail = getServiceAccountEmail();
X509Certificate2 certificate = new X509Certificate2(AppDomain.CurrentDomain.BaseDirectory + "certs//" + certificateFile, certificatePassword, X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar },
User = user
}.FromCertificate(certificate));
Google.Apis.Calendar.v3.CalendarService service = new Google.Apis.Calendar.v3.CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Test",
});
try
{
Event evv = service.Events.Get(user, "6ebr4dp452m453n468movuntag").Execute();
EventsResource.UpdateRequest ur = new EventsResource.UpdateRequest(service, evv, user, evv.Id);
ur.Execute();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
错误消息是指定的值不是有效的带引号的字符串."
The Error message is " The specified value is not a valid quoted string. "
这是始终有效的基本代码.我们仍然可以查询和插入事件.由于某些原因,更新刚刚停止工作?
This is basic code that always works. We can still query and insert Events. For some reason updates have just stopped working?
还有其他人得到这个吗?
Anybody else getting this?
推荐答案
我发现了问题所在:Google API的ETag功能似乎已损坏.
I found what is the problem: Google API's ETag functionality seems to be broken.
To get around the issue I had to download the source code of the .NET Google API client libraries from google-api-dotnet-client Downloads and commented the call to the method AddETag() on line 189 of ClientServiceRequest.cs; that method adds the If-Match ETag header that's currently causing the issues. This file is in the GoogleApis project.
public HttpRequestMessage CreateRequest(Nullable<bool> overrideGZipEnabled = null)
{
var builder = CreateBuilder();
var request = builder.CreateRequest();
object body = GetBody();
request.SetRequestSerailizedContent(service, body, overrideGZipEnabled.HasValue
? overrideGZipEnabled.Value : service.GZipEnabled);
//AddETag(request);
return request;
}
有关Google如何使用Google的更多信息,请参见协议参考:更新条目. API使用ETag和If-Match标头.
See Protocol Reference: Updating Entries for more information on how Google API's use ETags and the If-Match header.
这篇关于更新提供错误的日历事件“指定的值不是有效的带引号的字符串"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!