Skip to content

Latest commit

 

History

History
 
 

demonstration-fetch-data-from-a-shared-google-sheet

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Demonstration, Tutorial: Fetch data from a shared Google sheet

Tags: CSV, Demonstration, HTTP, Tutorial

This task script demonstrates using the "http" action to retrieve data from a shared Google sheet, using a GET request. It also includes a basic alert email that will be sent to the configured recipients if Mechanic is unable to access the shared sheet as a CSV.

Default options

{
  "gsheet_url__required": "https://docs.google.com/spreadsheets/d/e/2PACX-1vRFPR2f9l-w5dSTlcl_ld-mpyqmikI9mupNuc96YLJfmfVqK2c_CJe2_hJkSUVRS-u7jqh8T1jUk-OI/pub?gid=0&single=true&output=csv",
  "alert_email_recipients__array_required": [
    "[email protected]"
  ]
}

Learn about task options in Mechanic

Subscriptions

mechanic/user/trigger
mechanic/actions/perform

Learn about event subscriptions in Mechanic

Documentation

This task script demonstrates using the "http" action to retrieve data from a shared Google sheet, using a GET request. It also includes a basic alert email that will be sent to the configured recipients if Mechanic is unable to access the shared sheet as a CSV.

Review the tutorial for this task in the Mechanic docs to see the steps to share your own Google sheet.

Once the data has been successfully retrieved, it will be available in the mechanic/actions/perform event topic as an array of hashes, with the CSV column headers as the keys for each entry in the hash.

Sample Google sheet data:

| SKU    | Quantity |
|--------|----------|
| ABC123 |       10 |
| DEF456 |        0 |

Sample retrieved data:

[
  {
    "SKU": "ABC123",
    "Quantity": "10"
  },
  {
    "SKU": "DEF456",
    "Quantity": "0"
  }
]

Installing this task

Find this task in the library at tasks.mechanic.dev, and use the "Try this task" button. Or, import this task's JSON export – see Importing and exporting tasks to learn how imports work.

Contributions

Found a bug? Got an improvement to add? Start here: ../../CONTRIBUTING.md.

Task requests

Submit your task requests for consideration by the Mechanic community, and they may be chosen for development and inclusion in the task library!