【问题标题】:Google Spreadsheet Protocol "A cell's position cannot be updated."Google 电子表格协议“无法更新单元格的位置。”
【发布时间】:2013-11-20 23:46:21
【问题描述】:

我目前有一个 XML 文件需要发送给 Google 以更新我的工作表/电子表格中的单元格。我已经用一个库编写了 XML,我希望它的格式与Google's Spreadsheet API 要求的一样。

按照this 教程,我收到一条消息,上面写着“无法更新单元格的位置”。我不确定我做错了什么,但这是我在 Objective-C 中实现对 API 的调用的方式:

-(void) callAPI:(NSString *)apiURL withHttpMethod:(HTTPMethod)method XMLString:(NSString *) xml
{

NSString *urlString = [NSString stringWithFormat:@"%@?access_token=%@", apiURL, _accessTokenInfoDictionary[@"access_token"]];
NSLog(@"URLString: %@", urlString);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
                                initWithURL:[NSURL
                                             URLWithString:urlString]];
if (method == PUT) {

    [request setHTTPMethod:@"PUT"];

    [request setValue:@"application/atom+xml" forHTTPHeaderField:@"Content-Type"];

    [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[xml length]] forHTTPHeaderField:@"Content-length"];

    [request setHTTPBody:[xml dataUsingEncoding:NSUTF8StringEncoding]];

    [self makeRequest:request];
    }

}

我在 this 的帮助下使用 OAuth 2,但它不处理 xml 文件,因此我必须实现一个方法。

应用编写的 XML 文件如下所示:

<?xml version="1.0" encoding="UTF-8" ?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gs="http://schemas.google.com/spreadsheets/2006">
<id>https://spreadsheets.google.com/feeds/cells/theworksheetid/od6/private/full/R3C1</id>
<link rel="edit" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/cells/theworksheetid/od6/private/full/R3C1/15d60i" />
<gs:cell row="2" col="4" inputValue="Testing with XML Writer!!" />
</entry>

callAPI 方法生成的访问令牌如下所示:

https://spreadsheets.google.com/feeds/cells/theworksheetid/od6/private/full/R3C1/15d60i?access_token=some_access_token

所以,我不确定这是我实现该方法的方式,还是 XML 文件或访问令牌不允许我更新单元格,但任何帮助都可以,谢谢。

【问题讨论】:

    标签: ios objective-c xml oauth-2.0 google-spreadsheet-api


    【解决方案1】:

    问题解决了。问题是创建的 XML 文件中的行和列与提供给我的单元格条目中的行和列不匹配。所以我所要做的就是匹配它们,发送 XML 和 tada,现在我可以编辑单元格了!

    【讨论】:

      猜你喜欢
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多