Page 1 of 1
Google Scripts
Posted: Mon Nov 19, 2018 7:44 am
by garyapotter
Has anyone been playing around with the Google Scripts?
I would like to yet dont seem to be haveing much joy.
I have had a look on github and am still floundering... Help with setting up the connection of this app to the Simpro API would be appriciated.
https://script.google.com
Re: Google Scripts
Posted: Mon Nov 19, 2018 12:57 pm
by michelle
Hi Gary,
I've managed to get a google script working in Google Sheets. Had some trouble initially with the api authentication this is what worked for me in the end.
Code: Select all
var options = {
"headers": {
"Authorization":"Bearer 8f7aef2a1e4287d763f333xxxxxxxxxxxxxxxxx",
"Content-Type":"application/json",
"Accept": "application/json"
},
"muteHttpExceptions" : true
};
It seems you have to use
as well as
for it to work. This was using API-Key, obviously replace the Bearer token with your own.
Re: Google Scripts
Posted: Tue Nov 20, 2018 1:28 am
by garyapotter
Michelle,
Your reply really helped, thank you.
I am not too sure what ( "muteHttpExceptions" : true ) means as yet though this code is what got me started. If someone want to add it github that would be great.
Regards,
Gary
Code: Select all
function run() {
var url = 'https://BULDNAME.simprosuite.com/api/v1.0/companies/X/jobs/XXXXX';
var response = UrlFetchApp.fetch(url, {
"headers": {
"Authorization":"Bearer 5af829ccXXXXXXXXXXXXXXXXXXXXXXb6343f",
"Content-Type":"application/json",
"Accept": "application/json"
}
});
var result=JSON.parse(response);
Logger.log(result)
}