Question Details

Answered
Send image using Google Apps Script

Hi guys,

I've just started developing a bot that I will use with a Google Form and GAS. I have the bot working no problem with text however, now I may need to send a submitted picture also. I've search and searched and read and read but can't get a working solution. My current text code is:

 function sendLineNotify(message){
  var token = "f - - - - - 5"
  var options =
   {
     "method"  : "post",
     "payload" : "message="+message,
     "headers" : {"Authorization" : "Bearer " + token}
   };
   UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options);
}

I've tried several different ways of trying to modify the payload to send an image with no success. I get a server errors 400 "the message can't be empty" or invalid request etc

function sendLineNotify(message) {

	var message =
		
		var token = "fP------U5"
		var options = {
		"method" : "post",
		"message=" : {
			"type" : "image",
			"originalContentUrl" : "https://lh3.ggpht.com/6jmzKXoPG4WCSvUWn8ZpFYb2HNO6oMwPoKH36BrGT_Mril1JrMkUs9cEBlyoc4gVNw=s128.jpg",
			"previewImageUrl" : "https://lh3.ggpht.com/6jmzKXoPG4WCSvUWn8ZpFYb2HNO6oMwPoKH36BrGT_Mril1JrMkUs9cEBlyoc4gVNw=s128.jpg",
			"animated" : false
		},
		"headers" : {
			"Authorization" : "Bearer " + token
		}
	};
	Logger.log(UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options));
}

Is it possible to send an image using GAS, I assume it is just my lack of knowledge is letting me down.

0
Edited: 9 months ago
Profile picture
James D ����

Answers

1
Profile picture
Aekawit
Posted: 6 days ago

https://moremeng.in.th/2019/02/send-message-to-line-notify-with-google-form-app-script.html

Are you sure? question.vm