@NHN read is GET and write is PUT, not POST. Is your Google Sheet private? If it is you also need to provide the API key.
Edit: actually all sheets look like they need the API key, private Sheets appear to require an OAuth 2.0 client ID.
To read cells A1:B1 of a public sheet this syntax works in a web browser:
https://sheets.googleapis.com/v4/spreadsheets/sheetID?includeGridData=true&ranges=A1%3AB2&key=API_KEY
and returns:
{
"spreadsheetId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"properties": {
"title": "TestSheet",
"locale": "en_GB",
"autoRecalc": "ON_CHANGE",
"timeZone": "Europe/Helsinki",
"defaultFormat": {
"backgroundColor": {
"red": 1,
"green": 1,
"blue": 1
},
"padding": {
"top": 2,
"right": 3,
"bottom": 2,
"left": 3
},
"verticalAlignment": "BOTTOM",
"wrapStrategy": "OVERFLOW_CELL",
"textFormat": {
"foregroundColor": {},
"fontFamily": "arial,sans,sans-serif",
"fontSize": 10,
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false
}
}
},
"sheets": [
{
"properties": {
"sheetId": 0,
"title": "Sheet1",
"index": 0,
"sheetType": "GRID",
"gridProperties": {
"rowCount": 1000,
"columnCount": 26
}
},
"data": [
{
"rowData": [
{
"values": [
{
"userEnteredValue": {
"stringValue": "Costas"
},
"effectiveValue": {
"stringValue": "Costas"
},
"formattedValue": "Costas",
"effectiveFormat": {
"backgroundColor": {
"red": 1,
"green": 1,
"blue": 1
},
"padding": {
"top": 2,
"right": 3,
"bottom": 2,
"left": 3
},
"horizontalAlignment": "LEFT",
"verticalAlignment": "BOTTOM",
"wrapStrategy": "OVERFLOW_CELL",
"textFormat": {
"foregroundColor": {},
"fontFamily": "arial,sans,sans-serif",
"fontSize": 10,
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false
},
"hyperlinkDisplayType": "PLAIN_TEXT"
}
},
{
"userEnteredValue": {
"stringValue": "the coder."
},
"effectiveValue": {
"stringValue": "the coder."
},
"formattedValue": "the coder.",
"effectiveFormat": {
"backgroundColor": {
"red": 1,
"green": 1,
"blue": 1
},
"padding": {
"top": 2,
"right": 3,
"bottom": 2,
"left": 3
},
"horizontalAlignment": "LEFT",
"verticalAlignment": "BOTTOM",
"wrapStrategy": "OVERFLOW_CELL",
"textFormat": {
"foregroundColor": {},
"fontFamily": "arial,sans,sans-serif",
"fontSize": 10,
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false
},
"hyperlinkDisplayType": "PLAIN_TEXT"
}
}
]
}
],
"rowMetadata": [
{
"pixelSize": 21
},
{
"pixelSize": 21
}
],
"columnMetadata": [
{
"pixelSize": 100
},
{
"pixelSize": 100
}
]
}
]
}
]
}
Unfortunately the Webhook doesn’t seem to like the includeGridData=true part of the url. It might be because the json stream is just too big but I suspect it is an issue with Google’s API.
It works without this part of the url but as you will see from the Serial Monitor details below it doesn’t actually give you A1:B2 !!!
{
"spreadsheetId": "**********************************",
"properties": {
"title": "TestSheet",
"locale": "en_GB",
"autoRecalc": "ON_CHANGE",
"timeZone": "Europe/Helsinki",
"defaultFormat": {
"backgroundColor": {
"red": 1,
"green": 1,
"blue": 1
},
"padding": {
"top": 2,
"right": 3,
"bottom": 2,
"left": 3
},
"verticalAlignment": "BOTTOM",
"wrapStrategy": "OVERFLOW_CELL",
"textFormat": {
"foregroundColor": {},
"fontFamily": "arial,sans,sans-serif",
"fontSize": 10,
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false
}
}
},
"sheets": [
{
"properties": {
"sheetId": 0,
"title": "Sheet1",
"index": 0,
"sheetType": "GRID",
"gridProperties": {
"rowCount": 1000,
"columnCount": 26
}
}
}
]
}