在谷歌电子表格更新单元返回错误"缺少资源版本ID" /"远程服务器返回错误:(400)错误的请求" [英] Updating cell in Google Spreadsheets returns error "Missing resource version ID" / "The remote server returned an error: (400) Bad Request."

查看:418
本文介绍了在谷歌电子表格更新单元返回错误"缺少资源版本ID" /"远程服务器返回错误:(400)错误的请求"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新在谷歌电子表格单元格值,但可惜的是收到一个错误:

I would like to update a cell value in Google Spreadsheets but unfortunatelly an error is received:

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

My code is very simple and is based on sample downloaded from https://developers.google.com/google-apps/spreadsheets/?csw=1#changing_contents_of_a_cell:

        SpreadsheetsService service = new SpreadsheetsService("MySpreadsheetIntegration-v1");

        // TODO: Authorize the service object for a specific user (see other sections)
        service.setUserCredentials("...", "...");            

        // Instantiate a SpreadsheetQuery object to retrieve spreadsheets.
        SpreadsheetQuery query = new SpreadsheetQuery();

        // Make a request to the API and get all spreadsheets.
        SpreadsheetFeed feed = service.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 = service.Query(cellQuery);

                // Iterate through each cell, updating its value if necessary.
                foreach (CellEntry cell in cellFeed.Entries)
                {
                    cell.InputValue = "Foooooo!";
                    cell.Update();
                }

            }
        }



错误引发以下行:

The error is raised on the following line:

                    cell.Update();



我用Google.GData版本2.2.0.0(的 http://code.google.com/p/google-gdata/ )。
你知道什么可能导致这个问题?

I use Google.GData version 2.2.0.0 (http://code.google.com/p/google-gdata/). Do you know what could cause this problem?

这个问题也已经报道gdata的蟒蛇客户端。希望它得到尽快解决。
http://code.google.com/p/gdata-python-client/issues/detail?id=692&sort=-opened&colspec=Opened%20Stars %20ID%20Type%20Status%20Priority%20Component%20Summary

This issue has also been reported in the gdata python client. Hope it gets fixed soon. http://code.google.com/p/gdata-python-client/issues/detail?id=692&sort=-opened&colspec=Opened%20Stars%20ID%20Type%20Status%20Priority%20Component%20Summary

感谢您!

推荐答案

我们打一周前同样的问题,当它看来,谷歌翻转所有电子表格,以新的格式。结果
这同样适用于通过创建的GData换新API为好。 400错误随处可见。

We hit this same issue about a week ago when it seems that Google flipped over all spreadsheets to the "new" format.
This goes for new ones created via the GData api as well. 400 errors everywhere.

我挖成跨越的GData变种库的报告(Python和Java中,净等),并最终发现了这个小金块:
< A HREF =http://stackoverflow.com/a/23438381/1685090> http://stackoverflow.com/a/23438381/1685090

I dug into the reports across the GData variant libraries (Python, Java, .Net etc) and eventually found this little nugget: http://stackoverflow.com/a/23438381/1685090

设置Etag的属性设置为*的答案:)

Setting the Etag property to "*" is the answer :)

需要明确的是,我们正在设置WorksheetEntry.Etag当我们想在运行Update()工作表,我们也可以通过SpreadsheetsService.Batch()执行批量更新时设置CellEntry.Etag。

To be clear, we're setting WorksheetEntry.Etag when we want to run Update() on a worksheet, and we're also setting CellEntry.Etag when doing batch updates via SpreadsheetsService.Batch().

到目前为止,这似乎很好地工作与谷歌的新的电子表格

So far it seems to work fine with Google's "new" spreadsheets.

这种方法的一个缺点是,任何并发/合并操作将被却早 - 基本上你告诉谷歌,你的更新必须在吹走任何其他并发前值细胞。

One catch with this approach is that any concurrent/merging operations will be foregone - essentially you are telling Google that your update must blow away any other concurrent prior value in the cells.

这篇关于在谷歌电子表格更新单元返回错误&QUOT;缺少资源版本ID&QUOT; /&QUOT;远程服务器返回错误:(400)错误的请求&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆