Google Sheets – How to Use Google Spreadsheets to Post to a Web Service

google sheets

I was wondering, as a thought experiment, if it were possible to use Google Spreadsheets to post to a web service.

For example imagine you created a spreadsheet for guests attending a party with columns – first name, last name, allergies, meal preferences since it is so easy to share and sync you send a link to it to everyone you can think of. But being a geek you would like the data to populate a MySQL server (or whatever) so you can create a fancy website or reminder or social thingy (or whatever).

Is this possible? I have tried reading the API but it does not appear to be but maybe I have missed something.

Best Answer

Yes, populating an external service should be possible in a few different ways, all involving Google Apps Scripts:

  1. By using the JDBC service to populate an external database directly
  2. By using the URLFetch service to call an external web service
  3. By pulling data from the spreadsheet from an external app

In any case, you would need to set up a trigger script that will run when a response is submitted to your spreadsheet.

Option 1 might be out of the question if your database is behind a firewall. If you're not keen on doing a lot of Google Apps scripting, a good compromise could be to have a small trigger script ping an external web service to notify it of the new data. The external service would then poll the Google Spreadsheet for data, using for example the XML API.

You say it's just a thought experiment for now (too bad - it sounds like a fun project), but in any case I would really recommend reading up on Google Apps Script. It is a fairly new feature in Google Docs/Drive, and really makes it possible to create quite powerful webapps.