Discussions
Google Apps Script Rest Api - response from Service8 = Invalid username or password
3 days ago by Richard Kinsella
While waiting for a reply to my post of yesterday ChatGPT gave me some help to attempt to create a new job when a new record is added to a Google Sheet.
Please confirm if I have entered the correct credentials in the code:
Note everything inside the " " was replaced
var apiKey = "[App Secret]"; // Replace with your ServiceM8 App Secret
var businessUUID = "[end of login URL]"; // eg after auth= https://go.servicem8.com/dashboard?&s_auth=abcdefghijklmnopqrstuvwxyz10987654321
The further down the script was this code
"Authorization": "Basic " + Utilities.base64Encode(apiKey + ":x")
When the apps script was triggered the following was returned
"Invalid username or password"
ChatGPT suggested removing the x
"Authorization": "Basic " + Utilities.base64Encode(apiKey + ":"), // x removed for testing
Which returned "Authorization Required" which I think suggests the line with the x was correct but wrong credentials were used.
Have I used the wrong credentials or have I gone about this completely incorrectly?