【GAS】Sending POST and GET requests with Google Apps Script
You can send requests with the UrlFetchApp.fetch method.
Google Apps Script – UrlFetchApp
POST request
function sendPostRequest() {
var data = {
'name': 'Bob Smith',
'age': 35,
'pets': ['fido', 'fluffy']
};
var headers = {
"key":********
};
var options = {
"headers": headers,
"Content-Type": "application/json"
"method": "post",
"payload": JSON.stringify(data)
};
UrlFetchApp.fetch("http://example.com", options);
}
GET request
function sendGetRequest() {
var response = UrlFetchApp.fetch("http://www.google.com/");
console.log(response.getContentText())
}
Discussion
New Comments
No comments yet. Be the first one!