Google Scripts

Posts about the simPRO API. Help/support/how-to etc.
Forum rules
  • Check the documentation first. Before posting questions, please check the documentation to ensure it doesn't already cover what you need.
  • No spam. All automated messages, advertisements, and links to competitor websites will be deleted immediately.
  • Post in relevant sub-forums only. Messages posted in the wrong topic area will be removed and placed in the correct sub-forum by moderators.
  • Respect other users. No flaming or abusing fellow forum members. Users who continue to post inflammatory, abusive comments will be deleted from the forum after two warnings are issued by moderators.
  • Harassment. No threats or harassment of other users will be tolerated. Any instance of threatening or harassing behavior is grounds for deletion from the forums.
  • Adult content. No profanity or pornography is allowed. Posts containing adult material will be deleted.
  • Bandwidth. All images and signatures must be 500 x 500 pixels or smaller. Posts containing over-sized images and signatures will be removed.
  • Illegal content. No re-posting of copyrighted materials or other illegal content is allowed. Any posts containing illegal content or copyrighted materials will be deleted.
Post Reply
garyapotter
Posts: 4
Joined: Sun Nov 11, 2018 11:54 am

Google Scripts

Post by garyapotter » Mon Nov 19, 2018 7:44 am

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
User avatar
michelle
Posts: 132
Joined: Tue Jul 03, 2018 12:30 pm
Location: Brighton
Contact:

Re: Google Scripts

Post by michelle » Mon Nov 19, 2018 12:57 pm

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

Code: Select all

Accept
as well as

Code: Select all

Content-Type
for it to work. This was using API-Key, obviously replace the Bearer token with your own.
garyapotter
Posts: 4
Joined: Sun Nov 11, 2018 11:54 am

Re: Google Scripts

Post by garyapotter » Tue Nov 20, 2018 1:28 am

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)
}
Post Reply