1
votes

In another stackoverflow question, the questioner described the following scenario. I am quoting his earlier question because I am having the same issue when I try to POST to a Sheet. GET works fine. I can not tell from the prior questions discussion whether it was actually resolved relative to POST requests.

"I'm having no luck getting a response from v4 of the Google Sheets API when running against a public spreadsheet.

The relevant documentation states:

"If the request doesn't require authorization (such as a request for public data), then the application must provide either the API key or an OAuth 2.0 token, or both—whatever option is most convenient for you."

And to provide the API key, the documentation states:

"After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs."

So, I should be able to get a response listing the sheets in a public spreadsheet at the following URL:

https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}?key={myAPIkey}

(with, obviously, the id and key supplied in the path and query string respectively)

However, when I do this, I get an HTTP 401 response."

Is it possible to use an APIkey based access (rather than Oauth2) to POST to a Google Sheet using the v4 Sheets API?

1

1 Answers

1
votes

It seems that you cannot use an API key here because it will require you an authentication credentials. I tried it myself, but I'm getting an error that "The caller does not have permission" even though I am the owner of the spreedsheet.

Try to check these related threads if it can help you.