Reputation: 6117
I've been reading the docs extensively for sheets v4. I'm trying to post form data to a google spreadsheet with just the apikey (not using oauth). I don't want clients/users to have to login to be able to fill out my form.
The docs indeed says oauth only. Is there no way around this? Is there anyway to send a simple form's data to a google sheet?
This is the code I'm trying.
const postURL = `https://sheets.googleapis.com/v4/spreadsheets/1GOSI8dDYmuBIznSV-Ge9WtY_RSivo6rEpnpC8EZDnuw/values/orders!:append?insertDataOption=INSERT_ROWS&valueInputOption=RAW&key=mykey`;
let opts = {
method: 'POST',
body: JSON.stringify({
// "range": 'orders',
"majorDimension": 'ROWS',
"values": [
this.state.email
],
})
}
e.preventDefault()
fetch(postURL, opts)
.then(response => console.log('Success!', response))
.catch(error => console.error('Error!', error.message))
}
Upvotes: 2
Views: 1735
Reputation: 6117
As the commenters, you can't. You can only GET with the api key. Darn!
But, here's a pretty good guide on how to submit forms using a script on the spreadsheet side:
https://github.com/jamiewilson/form-to-google-sheets
Upvotes: 3