Here's the request URL format I am using currently:
postResURL = https://sheets.googleapis.com/v4/spreadsheets/${SHEET_ID}/values/Reserved!B2:D7:append?valueInputOption=RAW&key=${API_KEY}
Here is my demo code:
const newRow = [[Date.now().toString(), '[email protected]', 'some u']];
$.post({
url: postResURL, contentType: 'application/json', data: JSON.stringify(newRow),
}).done(function(response) {
if (response.updates) {
console.log('Row added successfully:', response);
} else {
console.error('Error adding row:', response);
alert('Error adding row.');
}
I kept on getting errors that looks like this:
{
"error": {
"code": 403,
"message": "Method doesn't allow unregistered callers (callers without established identity). Please use API Key or other form of API consumer identity to call this API.",
"status": "PERMISSION_DENIED"
}
}
I checked my google sheet permissions, all the permissions allow for writing.
Interestingly, $.get() works to read values, so I am able to read values from a google sheet, therefore API keys and Client_ID must be correct. However, I don't know why I can't write values to the google sheet, I tried using different combinations of the request URL, I'm not sure if that's the issue or not.
Here's the request URL format I am using currently: https://sheets.googleapis.com/v4/spreadsheets/${SHEET_ID}/values/Reserved!B2:D7:append?valueInputOption=RAW&key=${API_KEY}
, if you are trying to use "Method: spreadsheets.values.append" with the API key, unfortunately, in the current stage, the API key can be used to only GET method of Sheets API. So, please use it with the access token. But, if I misunderstood your script, I apologize.Maybe I need to switch to access tokens but I can't find information on the website. Can you provide more detail?
, how about this official document? developers.google.com/identity/protocols/oauth2