I am trying to set up a regular mailing list from Google tables according to the list of contacts from a group specially created for this purpose. All preparatory actions are done. With a GET request, everything works fine.
function vkSendMsg(id, msg) { var token = VALID_MSG_TOKEN; var user_id = id; var message = msg; var apiMsg = "https://api.vk.com/method/messages.send" var response = UrlFetchApp.fetch(apiMsg+"?"+"user_id="+user_id+"&"+"message="+message+"&"+"access_token="+token); Logger.log(response.getContentText()); } //Все ок But I want to do it with the help of POST
function vkSendMsgPost(id, msg) { var token = VALID_MSG_TOKEN; var user_id = id; var message = msg; var apiMsg = "https://api.vk.com/method/messages.send"; var data = { 'user_id': user_id, 'message': message, 'access_token': token }; var options = { 'method' : 'post', 'contentType': 'application/json', 'payload' : JSON.stringify(data) }; var response = UrlFetchApp.fetch(apiMsg, options); Logger.log(response.getContentText()); }//Возвращает ошибку авторизации (№5) Error: {"error": {"error_code": 5, "error_msg": "User authorization failed: no access_token passed.", "Request_params": [{"key": "oauth", "value": "1" }, {"key": "method", "value": "messages.send"}]}}
What am I doing wrong? And what needs to be done so that the messages are still sent?