Calling Local Services API in Google Sheet

597 views
Skip to first unread message

Basil Latif

unread,
Nov 29, 2021, 10:57:25 AM11/29/21
to Google Ads Scripts Forum
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')

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

Basil Latif

unread,
Nov 30, 2021, 11:07:33 AM11/30/21
to Google Ads Scripts Forum
Let me provide some more information: 
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 this error: Exception: Request failed for https://localservices.googleapis.com returned code 400. Truncated server response: { "error": { "code": 400, "message": "Invalid JSON payload received. Unknown name \"manager_customer_id:2845561262\": Cannot bind query p... (use muteHttpExceptions option to examine full response)


Does my call look correct? Do I need to feed in a request body too?

Google Ads Scripts Forum Advisor

unread,
Dec 1, 2021, 3:01:52 AM12/1/21
to adwords...@googlegroups.com
Hello Basil,

Thanks for reaching out. Harry here, from the Google Ads Scripts Team.

Unfortunately, our team can only provide assistance with the use or implementation of Google Ads scripts so I regret to inform that I won't be able provide insights on the the Local Services API you are trying to utilize. That being said, I recommend reaching out to the Google Apps Script Team/Community instead for better assistance regarding your concern.

Should you need help with Google Ads scripts, please let me know.

Thanks,
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2RwrQ3:ref

Basil Latif

unread,
Dec 6, 2021, 11:52:14 PM12/6/21
to Google Ads Scripts Forum
Hi, 
So according to Google's own documentation. The scope to call when using the Local Services API is -- https://www.googleapis.com/auth/adwords

The only difference is that I am making the call using Google Apps Script. Can you tell me what parameters I am supposed to include when making a request to the "adwords" API???

Your help is greatly appreciated. 

Google Ads Scripts Forum Advisor

unread,
Dec 7, 2021, 3:38:35 AM12/7/21
to adwords...@googlegroups.com
Hi Basil,

Thanks for coming back. It would really best to reach out to Google Apps Script Team/Community for further information regarding the Local Services API you would like to use for your requirement and since you are using the Google Apps Script platform. I believe you can also reach out for assistance through the Google Apps Script Community (Google Group) and the AdWords API and Google Ads API Forum as you need help with the AdWords API.

Let me know if you need help with Google Ads scripts.
Reply all
Reply to author
Forward
0 new messages