我是 golang 的新手,我正在编写一个脚本来使用传入的 webhook 向 slack 发送消息。
slackBody, _ := json.Marshal(SlackRequestBody{Text: msg, EventName: "xxx", AccountId: "xxx",
EventTime: "xxxxx", UserName: "xxxx", yyy: "xx", Status: "xx"})
fmt.Println(string(slackBody))
//test := ioutil.ReadAll(bytes.NewBuffer(slackBody))
req, err := http.NewRequest(http.MethodPost, webhookUrl, bytes.NewBuffer(slackBody))
if err != nil {
return err
}
req.Header.Add("Content-Type", "application/json")
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
这个帖子请求只包含“req”请求的几个字。你能帮我弄清楚这个问题吗?
慕哥9229398
森林海
随时随地看视频慕课网APP
相关分类