Apple,  Programming

Google Cloud Function To Create A Google Doc

Here’s a Google Cloud Function that creates a Google Doc based on a title and body from a json document:

https://github.com/krypted/tinyconverters/blob/main/json_to_new_google_doc.py

To use it, you’ll need to enable the Google Docs API from the Google Cloud Project and create a service account to get a JSON key file that’s saved in the same folder the cloud function is uploaded to. Once the Cloud Function is deployed, grab the URL and use it as follows:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "title": "My Super Sweet Title",
    "text": "This is the content of my super sweet document."
  }' \
  https://us-central1-PROJECT_ID.cloudfunctions.net/createDocument