Search code examples
curlgoogle-sheets-api

Row appends to existing data in wrong column


I have only one row 1,[space],3 which I input it manually:

Then I want to append a new row with 3 cells 1,2,3 using the Sheets REST API

curl -X POST \
  'https://sheets.googleapis.com/v4/spreadsheets/12_Ci93pDWrmQGLt3D5jg_Vb7Xi7vmHI9o62F58dpLeA/values/aaa%21A1%3AC1:append?insertDataOption=INSERT_ROWS&valueInputOption=RAW' \
  -H 'authorization: Bearer ya29.GlvgBH1pkFnZKs8cz0s0o7VyPUloPma1i2ZU-JUJGczIfFGy1Iw2XJUOMh4L9r2pTNYYVsmhMdf-2LfW4J38RMe5FosfeQjcTsZ6SiIGq1wcDzvSQjeHdY0P7iDh' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'postman-token: b6de9e14-d792-98a5-6d6d-183a1034cea5' \
  -d '{ "majorDimension": "ROWS", "values": [ [ "1", "2", "3" ] ] } '

It's strange that the newly added row has two spaces at the head [space],[space],1,2,3, if the first row has no space, it would be normal as 1,2,3

Please advise: how can I add it without these 2 spaces?


Solution

  • If there is one row, and you want to append a new row (1,2,3). The range either should be A2:C2 or A1.

    I put A1:C1, it causes incorrect behavior.