xml – 通过cURL向Google电子表格添加一行 – 必填字段错误

前端之家收集整理的这篇文章主要介绍了xml – 通过cURL向Google电子表格添加一行 – 必填字段错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以文档 here非常清楚地表明,使用XML格式的字段名将POSTing XML添加到表单的列表Feed 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终结点开机.工作表端点期望像您所看到的标题和rowCount.你想要的是一个看起来像的URL
https://spreadsheets.google.com/Feeds/list/$spreadsheet_id/$worksheet_id/private/full

我设置了a spreadsheet测试三列:

>水果
>颜色
>尺寸

我用苹果,红色,中等的方式播放它(hah!),因为我测试了auth和阅读,然后用这个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身份验证令牌
> $spreadsheet_id是网址中可见的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>

我注意到这些列都已经被低估了 – 我不知道是否重要.我还注意到,除了结构化元素之外,当我获取行时,还有标题内容标签,但是标题是您看到的标题错误的红色鲱鱼.

<!-- 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 -->
原文链接:https://www.f2er.com/xml/292765.html

猜你在找的XML相关文章