Adding a row to Google Spreadsheet via cURL - required fields errors Adding a row to Google Spreadsheet via cURL - required fields errors xml xml

Adding a row to Google Spreadsheet via cURL - required fields errors


Got it working, here's a Gist with all of my scripts. From your URL, it looks like you might be POSTing to the add a worksheet endpoint instead of the add a list row endpoint. The worksheet endpoint expects title and rowCount like you're seeing. What you want is a URL that looks like

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

I set up a spreadsheet to test with three columns:

  • Fruit
  • Color
  • Size

I seeded it (hah!) with Apple, Red, Medium as I tested auth and reading, then added Orange, Orange, Medium with this cURL command:

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"

Where:

  • $auth is my Google auth token obtained from https://www.google.com/accounts/ClientLogin
  • $spreadsheet_id is the ID visible in the URL or obtained from https://spreadsheets.google.com/feeds/spreadsheets/private/full
  • $worksheet_idis the worksheet (one sheet/tab inside the whole document) obtained from https://spreadsheets.google.com/feeds/worksheets/$spreadsheet_id/private/full. I didn't see anywhere visible in the UI I could get the worksheet ID.

and data.xml looks like this:

<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>

I noticed that the columns have all been lowercased - I'm not sure if that matters. I also noticed there are title and content tags when I fetch the rows, in addition to the structured elements, but that title was a red herring for the title error you're seeing.

<!-- 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 -->


I was simply using the wrong URL - instead of referencing the List feed link element with rel="http://schemas.google.com/g/2005#post", I was referencing the Worksheet feed, which has also has a link element with the same rel but a different href.

From what I gather, the list feed URL and the list feed POST URL are the same, which is where the confusion began for me.