Answer the question
In order to leave comments, you need to log in
How to execute or convert JS script to Google Apps Script?
I want to send POST requests to Google Apps Script.
I tried to write the code myself, but in the end something did not work. Made a recommendation, but it looks like it's written in JavaScript. Since Google has its own code, I do not understand how to use these recommendations.
Here is the code I wrote in the app script which doesn't work:
function senler(){
var data = {
'access_token': 'ee------------------------------------------------6',
'vk_group_id': 1-------5,
'v': 2,
'vk_user_id': 6------5,
// 'bot_id': 356810,
'subscription_id': 0
};
var options = {
'method': 'post',
'payload': data,
};
var response = UrlFetchApp.fetch('https://senler.ru/api/subscribers/del', options);
Logger.log(response.getResponseCode());
}
const formData = new FormData();
for(const name in data) {
formData.append(name, data[name]);
}
const response = fetch(url, {
method: 'POST',
body: formData
});
Answer the question
In order to leave comments, you need to log in
Use a service that logs or shows incoming post requests. Then it will become clear what exactly was sent by your request. For example here .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question