gpt4 book ai didi

xml - 通过 cURL 在 Google 电子表格中添加一行 - 必填字段错误

转载 作者:数据小太阳 更新时间:2023-10-29 01:41:14 26 4
gpt4 key购买 nike

所以文档 here非常明确地说,将 XML 发布到具有此 XML 格式的字段名称的工作表的列表提要 url 将插入一个新行。

Auth 正在工作,授权帐户可以访问工作表。所有这些错误都已解决。

所以当我发布到 https://spreadsheets.google.com/feeds/list/key/mySheetIDHere/private/full没有我得到

“发布的条目缺少一个或多个必填字段:标题”

所以我添加了<title></title>除了之前存在的 <gsx:Title></gsx:Title>那消失了,但被替换为

“发布的条目缺少一个或多个必填字段:rowCount”

所以我尝试添加一个表示当前行数的 int,但错误仍然存​​在。

当前 XML 如下

<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">
<title>A Title</title>
<rowCount>3</rowCount>
<gsx:Title>A Title</gsx:Title>
<gsx:Name>A Name</gsx:Name>
<gsx:Email>An email</gsx:Email>
<gsx:Phone>A phone</gsx:Phone>
</entry>

文档没有提及必填字段或行数。有人知道我做错了什么吗?

最佳答案

成功了,这里是 a Gist with all of my scripts .从您的 URL 看来,您可能正在发布到 add a worksheet端点而不是 add a list row端点。工作表端点需要 titlerowCount 就像您看到的那样。你想要的是一个看起来像

https://spreadsheets.google.com/feeds/list/$spreadsheet_id/$worksheet_id/private/full

我设置了a spreadsheet使用三列进行测试:

  • 水果
  • 颜色
  • 尺寸

我在测试身份验证和阅读时用 Apple, Red, Medium 播种(哈!),然后使用此 cURL 命令添加 Orange, Orange, Medium:

curl \
--header "Authorization: GoogleLogin auth=$auth" \
--header 'Content-Type: application/atom+xml' \
-d @data.xml \
-X POST \
"https://spreadsheets.google.com/feeds/list/$spreadsheet_id/$worksheet_id/private/full"

地点:

  • $auth 是我从 https://www.google.com/accounts/ClientLogin
  • 获得的 Google 身份验证 token
  • $spreadsheet_id 是 URL 中可见的 ID 或从 https://spreadsheets.google.com/feeds/spreadsheets/private/full
  • 获取
  • $worksheet_id 是从 https://spreadsheets.google.com/feeds/worksheets/$spreadsheet_id/private/full 获得的工作表(整个文档中的一张纸/标签) 。我在 UI 中看不到任何可见的地方,我可以获取工作表 ID。

data.xml 看起来像这样:

<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">
<gsx:fruit>Orange</gsx:fruit>
<gsx:color>Orange</gsx:color>
<gsx:size>Medium</gsx:size>
</entry>

我注意到所有列都已小写 - 我不确定这是否重要。我还注意到,当我获取行时,除了结构化元素之外,还有 titlecontent 标签,但是 title 是一个转移话题对于您看到的 title 错误。

<!-- GET https://spreadsheets.google.com/feeds/list/$spreadsheet_id/$worksheet_id/private/full -->
<!-- snip -->
<title type="text">Apple</title>
<content type="text">color: Red, size: Medium</content>
<gsx:fruit>Apple</gsx:fruit>
<gsx:color>Red</gsx:color>
<gsx:size>Medium</gsx:size>
<!-- snip -->

关于xml - 通过 cURL 在 Google 电子表格中添加一行 - 必填字段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28508390/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com