I am still not understanding how fetch requests are structured. In my Chrome Extension, I have used an API key from my console to GET some values from a spreadsheet:
let fetch_url = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${range}?key=${API_KEY}`;
It worked, but when I want to append some values, it doesn't:
let fetch_url = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/Teachers!A7:D8:append?key=${API_KEY}`;
let fetch_options = {
"method": "POST",
"body": JSON.stringify({
"values": [
["Door", "$15", "2", "3/15/2016"],
["Engine", "$100", "1", "3/20/2016"],
]
})
};
I get a 401 response, what am I missing?
If you check the doucmentation sheet values
You will notice that it states
This is because this method is preformed on a private user data. This means that you need an authorization header with a valid oauth2 access token with one of those scopes in order to access that method.
Authorize the request and then you will be able to access the data. There is a javascript guild which might help you understand how to preform the authorization of your application.