Google Spreadsheets API and Column Names
I had a play with the Google Spreadsheets API recently to feed in some data from a C# application. The getting started guide is great and I was authenticated and adding dummy data in no time. But as soon as I started to work with real data I got:
"The remote server returned an error: (400) Bad Request."
And digging deeper into the response:
"We're sorry, a server error occurred. Please wait a bit and try reloading your spreadsheet."
The original sample code still worked so it didn't seem like any sort of temporary glitch as the message suggests. After much hair torn it turns out I was getting this error because I had used the literal column names from my spreadsheet. The API expects them to be lower case with spaces removed. If not columns match you get the unhelpful error above, if at least one column matches you get a successful insert with some missing data.
Error messages are one of the hardest parts of an API to get right. If you're not very detailed then what seems obvious to you can leave your developers stumped.
Hope this helps someone else...
Related Posts
- Monitor page index status with Google Sheets, Apps Script and the Google Search Console API
- Automate Google PageSpeed Insights and Core Web Vitals Logging with Apps Script
- Export Google Fit Daily Steps, Weight and Distance to a Google Sheet
- Reading and Writing Office 365 Excel from a Console app using the Microsoft.Graph C# Client API
- Migrating a C# Integration from GA3 to GA4
(Published to the Fediverse as: Google Spreadsheets API and Column Names #etc #google #api #spreadsheet A 400 bad request from the Google Spreadsheets API may be caused by incorrect column names. How to fix. )
Add Comment
All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.