Hi,
In one my apps I am using PUSHOVER api to send notifications. I am using HTTP POST for the API. Its working fine. But now i have a requirement to send an image along with the HTTP POST request. Is it possible. The image should be actual byte data and not url of image. Can I upload the actual binary data of image within the JSON content. Below is the documentation given by them but it is not for JSON format. Can a similar thing be done within JSON or any other method within appsheet
Below is what i normally use inside the JSON Body. I need to add attachment in this code. Can someone help me with this.
{
"token": "asdfghjkl",
"user": "lkjhgfdsa",
"title":"<<[Title]>>",
"message": "<<[Body]>>",
"sound":"bike",
"url":"<<"https://www.appsheet.com/start/123456789"&[DeepLink]>>",
"url_title":"View Full Details"
}
Solved! Go to Solution.
Hello @jyothis_m . Tried to create a set up and successfully made it.
Here are the details
Here is the formula to get the image link from virtual columm
CONCATENATE( "https://www.appsheet.com/template/gettablefileurl","appName=",ENCODEURL(CONTEXT("AppName")), "&tableName=",ENCODEURL(CONTEXT("Table")),"&fileName=",ENCODEURL([Image]))
App must disable to security setting in order to fetch the image
Here is log of image link successfully fetch
Create an automation to appscript
Here is the appscript code
function form_data(e) {
var youtubeLogoUrl =e;
Logger.log(e)
var file = UrlFetchApp
.fetch(youtubeLogoUrl)
.getBlob()
.setName("youtubeLogoBlob");
var url = "https://api.pushover.net/1/messages.json";
var form = {
token : "apri2xcbvwnbstrzsssu85tosq9i33",
user : "ucw7i37vs8c65bbc4d9nxnv698esj4",
device : "21091116ag",
title : "Backup finished - SQL1",
message : " Backup of database example finished in 16 minutes.",
attachment : file
};
send_pushover(url,form);
}
function send_pushover(url,form) {
var options = {
method : "POST",
payload : form
};
var response = UrlFetchApp.fetch(url,options);
Logger.log(response)
}
Test result
โ
Hope you understand it.
You can easily do it via appscript. You need to create I think blob oject. Attached as one of the parameters.
Hi @AngeloParana Thanks for the reply. But how do i get the image from appsheet to appscript. I tried the API separately with form-data body and image is sending successfully. Is there a similar way possible in JSON body.
Hello @jyothis_m You may check on this thread how to get the file lin
Then use Urlfetchapp to pass the value like this
โ
Thank you @AngeloParana Shall try this
Hi @AngeloParana I tried but didn't succeed. I have very little knowledge in coding, Below is the code i am using in appscript, can you please guide me to implement it. The notification is reaching correctly but no attachment. Can you help me where I am going wrong.
Hello @jyothis_m . Tried to create a set up and successfully made it.
Here are the details
Here is the formula to get the image link from virtual columm
CONCATENATE( "https://www.appsheet.com/template/gettablefileurl","appName=",ENCODEURL(CONTEXT("AppName")), "&tableName=",ENCODEURL(CONTEXT("Table")),"&fileName=",ENCODEURL([Image]))
App must disable to security setting in order to fetch the image
Here is log of image link successfully fetch
Create an automation to appscript
Here is the appscript code
function form_data(e) {
var youtubeLogoUrl =e;
Logger.log(e)
var file = UrlFetchApp
.fetch(youtubeLogoUrl)
.getBlob()
.setName("youtubeLogoBlob");
var url = "https://api.pushover.net/1/messages.json";
var form = {
token : "apri2xcbvwnbstrzsssu85tosq9i33",
user : "ucw7i37vs8c65bbc4d9nxnv698esj4",
device : "21091116ag",
title : "Backup finished - SQL1",
message : " Backup of database example finished in 16 minutes.",
attachment : file
};
send_pushover(url,form);
}
function send_pushover(url,form) {
var options = {
method : "POST",
payload : form
};
var response = UrlFetchApp.fetch(url,options);
Logger.log(response)
}
Test result
โ
Hope you understand it.
You are Amazing!!! ๐ค @AngeloParana It worked flawlessly. Thanks a lot for your help. I was struggling with the code needed in GAS. Thanks once again. ๐ค
User | Count |
---|---|
36 | |
31 | |
28 | |
23 | |
18 |