gpt4 book ai didi

c# - 使用 C# 更新 Google 电子表格

转载 作者:太空宇宙 更新时间:2023-11-03 15:51:53 24 4
gpt4 key购买 nike

这是我第一次在这里发帖,我是使用 Google API 的新手。我遇到的问题是我正在尝试登录我的 Google 云端硬盘帐户并更新电子表格中的特定单元格。我可以登录我的 Google 云端硬盘,但当我尝试访问 Google 电子表格时,出现“解析失败”错误。

using System;
using Google;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;
using Google.Apis.Services;

UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
{ClientId = "XXXXX.apps.googleusercontent.com",ClientSecret = "XXXXX", }, new[] { DriveService.Scope.Drive }, "user", CancellationToken.None).Result;


var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive API Sample",
});

SpreadsheetsService services = new SpreadsheetsService("site");
SpreadsheetQuery query = new SpreadsheetQuery();
SpreadsheetFeed feed = services.Query(query);`

当我到达 services.Query(query) 时,我收到解析失败错误。任何帮助将不胜感激。

这是完整的错误

Google.GData.Client.ClientFeedException was unhandled
HResult=-2146233088
Message=Parsing failed
Source=Google.GData.Client
StackTrace:
at Google.GData.Client.AtomFeedParser.Parse(Stream streamInput, AtomFeed feed)
at Google.GData.Client.AtomFeed.Parse(Stream stream, AlternativeFormat format)
at Google.GData.Client.Service.CreateAndParseFeed(Stream inputStream, Uri uriToUse)
at Google.GData.Client.Service.Query(FeedQuery feedQuery)
at Google.GData.Spreadsheets.SpreadsheetsService.Query(SpreadsheetQuery feedQuery)
at webPull.Program.Main(String[] args) in C:\Users\shartnett\Documents\Visual Studio 2010\Projects\webPull\webPull\Program.cs:line 80
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Xml.XmlException
HResult=-2146232000
Message=Root element is missing.
Source=System.Xml
LineNumber=0
LinePosition=0
SourceUri=""
StackTrace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at Google.GData.Client.BaseFeedParser.MoveToStartElement(XmlReader reader)
at Google.GData.Client.AtomFeedParser.Parse(Stream streamInput, AtomFeed feed)
InnerException:

最佳答案

有一个Post here讨论了“解析失败”的问题。

它提到在 Fiddler 中看到对 http://www.w3.org/TR/html4/strict.dtd 的调用失败.

尝试使用 Fiddler 并查看哪些调用可能会失败。

关于c# - 使用 C# 更新 Google 电子表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25451158/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com