How to send Payload Body in Google Apps Script using POST Method

Photo by Shahadat Rahman on Unsplash

Hello Nerds. Here I will show you the example of how to send a payload body in Google Apps Script’s Post Method. This is nothing but the same use case of connecting third party API using google apps script.

Below is the example code

//Your JSON Paylod or Body
var subscribe = {
“name”: “sid",
“array_data”: [ 1, 2, 3]

var options = {

‘method’ : ‘post’,
‘contentType’: ‘application/json’,
‘headers’ : {
‘Authorization’ : “apiToken”
// Assuming you requires ApiToken to access the resources

‘payload’ : JSON.stringify(subscribe) //Here passing json in JSON.stringify

var res = UrlFetchApp.fetch(url, options);

I hope you all get it. It's simple but still, it may be helpful to someone someday, because i had also searched for a similar problem in the past.

If you want any assistance regarding Google Apps Script or G Suite Automation you can hire me or discuss here

Clap if you loved it.

Business Analyst | Bibliophile | Bitcoiner