0

I'm managing the users of my Notion page in Sheets. Each user has email. I want to automate providing access to that Notion. So that each time a user (email) is added to Sheets, it is auto added to Notion.

I've found a workaround for Notion API, which works fine (tested it with Postman).

What I can't do is creating a POST request to that API. Is there a way to make it directly from sheets?

I learned there is this App Script tool, which seems to run any code I like. But I'm not an engineer and can't find any sample code to use.

1 Answers1

1

To communicate with other applications using Apps Script, you can use the UrlFetchApp class. To use Apps Script with the Google Sheet where you have the list of emails, you need to create a bound script by opening the Google Sheet, in the top menu, go to Extensions > Apps Script. You can use the following sample code to make a POST request:

// Make a POST request with a JSON payload.
var data = {
  'name': 'Bob Smith',
  'age': 35,
  'pets': ['fido', 'fluffy']
};
var options = {
  'method' : 'post',
  'contentType': 'application/json',
  // Convert the JavaScript object to a JSON string.
  'payload' : JSON.stringify(data)
};
UrlFetchApp.fetch('https://httpbin.org/post', options);

Also, I found this thread with an specific use for Notion API.

You can use the installable event-driven trigger On edit to run the request automatically when the Google Sheet is modified.

Lorena Gomez
  • 1,946
  • 2
  • 4
  • 11