大佬教程收集整理的这篇文章主要介绍了c# – Google Spreadsheets中的更新单元格返回错误“缺少资源版本ID”/“远程服务器返回错误:(400)错误请求.”,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Google.GData.Client.GDatarequestException was unhandled HResult=-2146233088 message=Execution of request Failed: https://spreadsheets.google.com/Feeds/cells/1nW8nxoS2l9pbj6dctreEfKHNXmsfbbsCAvOd7TIj4Bo/od6/private/full/R1C1 source=Google.GData.Client ResponseString=Missing resource version ID StackTrace: at Google.GData.Client.GDatarequest.Execute() ... at System.Threading.ThreadHelper.ThreadStart() InnerException: System.Net.WebException HResult=-2146233079 message=The Remote Server returned an error: (400) Bad request. source=System StackTrace: at System.Net.httpWebrequest.GetResponse() at Google.GData.Client.GDatarequest.Execute()
我的代码非常简单,基于从https://developers.google.com/google-apps/spreadsheets/?csw=1#changing_contents_of_a_cell下载的示例:
Spreadsheets@R_607_9260@ce @R_607_9260@ce = new Spreadsheets@R_607_9260@ce("MySpreadsheeTintegration-v1"); // TODO: Authorize the @R_607_9260@ce object for a specific user (see other sections) @R_607_9260@ce.setUserCredentials("...","..."); // Instantiate a SpreadsheetQuery object to retrieve spreadsheets. SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed Feed = @R_607_9260@ce.Query(query); foreach (SpreadsheetEntry spreadsheet in Feed.Entries) { if (spreadsheet.title.Text == "Test01") { // Get the first worksheet of the first spreadsheet. WorksheetFeed wsFeed = spreadsheet.Worksheets; WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0]; // Fetch the cell Feed of the worksheet. CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink); cellQuery.MinimumRow = 1; cellQuery.MaximumRow = 10; cellQuery.Minimumcolumn = cellQuery.Maximumcolumn = 1; cellQuery.ReturnEmpty = ReturnEmptyCells.yes; CellFeed cellFeed = @R_607_9260@ce.Query(cellQuery); // Iterate through each cell,updating its value if necessary. foreach (CellEntry cell in cellFeed.Entries) { cell.InputValue = "Foooooo!"; cell.update(); } } }
在以下行引发错误:
cell.update();
我使用Google.GData版本2.2.0.0(http://code.google.com/p/google-gdata/).
你知道什么可能导致这个问题吗?
[编辑]此问题也在gdata python客户端中报告过.希望很快得到修复.
http://code.google.com/p/gdata-python-client/issues/detail?id=692&sort=-opened&colspec=Opened%20Stars%20ID%20Type%20Status%20Priority%20Component%20Summary
谢谢!
我深入研究了GData变体库(Python,Java,.Net等)的报告,并最终找到了这个小块:
https://stackoverflow.com/a/23438381/1685090
将Etag属性设置为“*”就是答案:)
为了清楚起见,我们在工作表上运行update()时设置WorksheetEntry.Etag,并且我们还在通过Spreadsheets@R_607_9260@ce.batch()进行批量更新时设置CellEntry.Etag.
到目前为止,似乎与谷歌的“新”电子表格一起工作正常.
这种方法的一个优点是任何并发/合并操作都将被放弃 – 实质上,您告诉Google您的更新必须清除单元格中的任何其他并发先前值.
以上是大佬教程为你收集整理的c# – Google Spreadsheets中的更新单元格返回错误“缺少资源版本ID”/“远程服务器返回错误:(400)错误请求.”全部内容,希望文章能够帮你解决c# – Google Spreadsheets中的更新单元格返回错误“缺少资源版本ID”/“远程服务器返回错误:(400)错误请求.”所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。