Kintone API Go

ローカル

func handler(w http.ResponseWriter, r *http.Request) {
    jar, _ := cookiejar.New(nil)
    client := &http.Client{Jar: jar}

    url := {URL}
    jsonStr := []byte(`{"app":"1","id":"7"}`)
    req, err := http.NewRequest("GET", url, bytes.NewBuffer(jsonStr))
    req.Header.Set("Content-Type", "application/json")
    apiToken := {APIトークン}
    req.Header.Set("X-Cybozu-API-Token", apiToken)

    res, err := client.Do(req)
    if err != nil {
        log.Println(err.Error())
    }
    buf := new(bytes.Buffer)
    buf.ReadFrom(res.Body)
    s := buf.String()
    log.Println(s)
}

app engine

func handler(w http.ResponseWriter, req *http.Request) {
    ctx := appengine.NewContext(req)
    client := urlfetch.Client(ctx)

    url := {URL}
    jsonStr := []byte(`{"app":"1","id":"7"}`)
    req, err := http.NewRequest("GET", url, bytes.NewBuffer(jsonStr))
    req.Header.Set("Content-Type", "application/json")
    apiToken := {APIトークン}
    req.Header.Set("X-Cybozu-API-Token", apiToken)

    res, err := client.Do(req)
    if err != nil {
        log.Debugf(ctx, err.Error())
    }
    buf := new(bytes.Buffer)
    buf.ReadFrom(res.Body)
    s := buf.String()
    log.Debugf(ctx, s)
}