I would like to GET information(data) from API and display it. Data is fetched from Big Query by using API.
Currently, I have written the code which potentially supposes to display information from API, but I'm not sure how to use service account as environmental.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
response, err := http.Get("https://www.googleapis.com/bigquery/v2/projects/PROJECT_ID/queries/JOB_ID")
if err != nil {
fmt.Printf("%s", err)
os.Exit(1)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Printf("%s", err)
os.Exit(1)
}
fmt.Printf("%s
", string(contents))
}
}
Expected result should be just to display data from API, then I will need to create an API which can be accessible without authentication with parameters (as GET Method)
P.S. Here is the link to API - https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/getQueryResults