Last active
October 4, 2022 08:05
-
-
Save boulama/9cf6e13459dda92219e15dfe513ab1b4 to your computer and use it in GitHub Desktop.
Create PDF with picsapi.com (google app script code)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCertificate(name, date) { | |
//=getCertificate(B2,C2) | |
var formData = { | |
transformations: { | |
date:{text:date}, | |
name:{text:name} | |
}, | |
template_id:'<template-id>', | |
format:'pdf' | |
} | |
var options = { | |
'method': 'post', | |
'contentType': 'application/json', | |
'payload': JSON.stringify(formData), | |
muteHttpExceptions: true, | |
} | |
console.log(options); | |
let api_key = '<api-token>'; | |
options.headers = {"Authorization": "Bearer " + api_key}; | |
var response = UrlFetchApp.fetch('https://api.picsapi.com/v1/make', options); | |
var responseCode = response.getResponseCode() | |
console.log(response.getContentText()); | |
if(responseCode != 200) { | |
return false; | |
} | |
else { | |
var data = JSON.parse(response.getContentText()); | |
console.log(data); | |
return data.data.url; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment