I am trying to append some data to a Google Sheets spreadsheet using a HTML POST Request. I am having some difficulty in solving the 404 error I get when sending the request. My request code is shown below:
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState == XMLHttpRequest.DONE) {
alert(httpRequest.status);
}
}
var params = {
"values": [
[
"value1",
"value2"
]
]
}
httpRequest.open('POST', 'https://sheets.googleapis.com/v4/spreadsheets/' + spreadsheetID + 'values/Sheet1!B2:L2:append', true)
httpRequest.setRequestHeader('Authorization', 'Bearer ' + accessToken);
httpRequest.setRequestHeader('Content-Type', 'application/json');
httpRequest.send(JSON.stringify(params));
I have gained the necessary permissions in the access token, since I am able to create sheets, but I think there might be an issue with my url. Thanks in advance!