这是我第一次在这里发帖,我是使用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(查询)我得到解析失败错误。任何帮助将不胜感激。
这是完整的错误
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:
答案 0 :(得分:0)
有Post here讨论"解析失败"问题。
它提到在Fiddler看到http://www.w3.org/TR/html4/strict.dtd失败的电话。
尝试使用Fiddler并查看可能失败的呼叫。