Calling Local Services API in Google Sheet

46 views
Skip to first unread message

Basil Latif

unread,
Dec 7, 2021, 10:52:43 AM12/7/21
to Google Apps Script Community
Hello! 

I am trying to call the Local Services API as documented here: https://services.google.com/fh/files/helpcenter/lsa_api_dev_guide.pdf

I want to pull in the reports into a Google Sheet. I have configured my Google Sheet and Google Apps Script using the steps written here: https://github.com/googleworkspace/apps-script-oauth2

I am unable to get a correct API response. Inside the method to call the service I am calling:
return OAuth2.createService('adwords')

I am structuring my request like this: 

function makeRequest() {
var driveService = getDriveService(); //this is the function that calls the adwords api
console.log(driveService)
var response = UrlFetchApp.fetch('https://localservices.googleapis.com/v1/accountReports:search?manager_customer_id:<manager customer id>', {
headers: {
Authorization: 'Bearer ' + driveService.getAccessToken() //getting the access token from the above call
},
'method' : 'get',
'contentType' : 'application/json'
});
console.log(response)
}

Currently, I am getting an empty response, looking like this: {}. 

Does anyone have any sample code and/or links to how to call this API in a Google sheet?

Does my call look correct? Do I need to feed in a request body too?
Reply all
Reply to author
Forward
0 new messages