Calling Google Apps Script from Golang

I’ve the below Google Apps script:

function doGet(request) {
  var events = CalendarApp.getEvents(
    new Date(Number(request.parameters.start) * 1000),
    new Date(Number(request.parameters.end) * 1000));
  var result = {
    available: events.length == 0
  return ContentService.createTextOutput(JSON.stringify(result))

Once I open the following url at browsr:

I get correct responce:


I’m trying to do the call through Go lang as:

package main

import (

func main() {
	site := ""
	base, err := url.Parse(site)
	if err != nil {

	// Path params
	//	base.Path += "this will get automatically encoded"

	// Query params
	params := url.Values{}

	params.Add("start", "1325437200")
	params.Add("end", "1325439000")
	base.RawQuery = params.Encode()

	fmt.Printf("Encoded URL is %q\n", base.String())

	// make a sample HTTP GET request
	res, err := http.Get(base.String())
	// check for response error
	if err != nil {

	// read all response body
	data, _ := ioutil.ReadAll(res.Body)

	// close response body

	// print `data` as a string
	fmt.Printf("%s\n", data)

But I’m not getting the same output, and getting very long text looks to be like extraction of Google login screen with multiple languages (regardless what the output is, it is not the expected one), I expect the output to be same what I got at the browser, i.e.


I found the error to be in the Web App publishing settings, by changing the settings of the settings of Execute as and Who has access from Me and Anyone with Google account to Me and Anyone, respectively I got it resolved.

Credit goes to Tanaike at stackoverflow

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.