第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang:帶有 JSON 負載的 http.NewRequest POST 返回錯誤 500

Golang:帶有 JSON 負載的 http.NewRequest POST 返回錯誤 500

Go
慕的地6264312 2021-09-13 19:49:27
我正在為 API 開發(fā)一個庫。當您發(fā)出 curl 命令時,有一個 API 端點 (POST):curl -H "X-API-TOKEN: API-TOKEN" 'http://interest-graph.getprismatic.com/text/topic' \  --data "title=Clojure" \  --data "body=Clojure is a dynamic programming language that targets the Java Virtual Machine (and the CLR, and JavaScript). It is designed to be a general-purpose language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming.Clojure is a compiled language - it compiles directly to JVM bytecode, yet remains completely dynamic. Every feature supported by Clojure is supported at runtime."我正在嘗試使用 http.NewRequest 執(zhí)行上述命令:   var jsonReq = []byte(`{"title": "Clojure", "body": "Clojure is a dynamic programming language that targets the Java Virtual Machine         (and the CLR, and JavaScript). It is designed to be a general-purpose language,         combining the approachability and interactive development of a         scripting language with an efficient and robust infrastructure for multithreaded programming.        Clojure is a compiled language - it compiles directly to JVM bytecode,         yet remains completely dynamic. Every feature supported by Clojure is supported at runtime."}`)    buf := new(bytes.Buffer)    err := json.NewEncoder(buf).Encode(jsonReq)    if err != nil {        fmt.Println(err)    }    u := "http://interest-graph.getprismatic.com/text/topic"    ApiToken := "API-TOKEN"    req, err := http.NewRequest("POST", u, buf)    req.Header.Set("Content-Type", "application/json")    req.Header.Set("X-API-TOKEN", ApiToken)    if err != nil {        log.Fatal(err)    }    c := http.DefaultClient    resp, err := c.Do(req)    if err != nil {        log.Fatal(err)    }    defer resp.Body.Close()    r, err := ioutil.ReadAll(resp.Body)    if err != nil {        log.Fatal(err)    }    fmt.Println(string(r))不確定我這樣做是否正確,因為我不斷收到錯誤 500。知道我做錯了什么嗎?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 202 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號