2
我可以打開工作表並從頭中讀取單元格。 Google電子表格中的第一行是標題,我在Google電子表格中手動添加了「名稱」,「my-val1」,「my-val2」,「my-val3」,「其他」。無法將行添加到Google Spreadsheet
下面是相關谷歌文檔:
https://developers.google.com/google-apps/spreadsheets/#adding_a_list_row
我想添加一行到工作表,但得到的,而一般的錯誤「遠程服務器返回錯誤:(400)錯誤的請求「。任何想法我做錯了什麼?
下面是代碼:
AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
ListFeed listFeed = myService.Query(listQuery);
ListEntry row = new ListEntry();
row.Elements.Add(new ListEntry.Custom() { LocalName = "Name", Value = "Joe" });
row.Elements.Add(new ListEntry.Custom() { LocalName = "my-val1", Value = "Smith" });
row.Elements.Add(new ListEntry.Custom() { LocalName = "my-val2", Value = "26" });
row.Elements.Add(new ListEntry.Custom() { LocalName = "my-val3", Value = "176" });
row.Elements.Add(new ListEntry.Custom() { LocalName = "Other", Value = "176" });
myService.Insert(listFeed, row);
以下是錯誤消息:
Google.GData.Client.GDataRequestException: Execution of request failed: https://spreadsheets.google.com/feeds/list/tlb-JYE8eZbWTRPCoqugCqw/od6/private/full ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at Google.GData.Client.GDataRequest.Execute()
--- End of inner exception stack trace ---
at Google.GData.Client.GDataRequest.Execute()
at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
at Google.GData.Client.GDataGAuthRequest.Execute()
at Google.GData.Client.Service.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data)
at Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data)
at Google.GData.Client.Service.Insert[TEntry](Uri feedUri, TEntry entry)
at Google.GData.Client.Service.Google.GData.Client.IService.Insert(AtomFeed feed, AtomEntry entry)
at Google.GData.Client.Service.Insert[TEntry](AtomFeed feed, TEntry entry)
at DesktopControl.GoogleSpreadsheet.addRow() in C:\Users\mark\Documents\Visual Studio 2008\Projects\DSCON\DSCON\GoogleSpreadsheet.cs:line 248}
我得到** System.Net.WebException:遠程服務器返回錯誤:(403)禁止。** – 2015-08-24 19:21:55