このような感じで json を POST できるかと思います。
go
1import (
2 "bytes"
3 "net/http"
4 "time"
5)
6
7func httpPost() error {
8 jsonStr := "{key: 'value'}"
9
10 req, _ := http.NewRequest(
11 "POST",
12 "https://www.example.com/api",
13 bytes.NewBuffer([]byte(jsonStr)),
14 )
15
16 req.Header.Set("Content-Type", "application/json")
17
18 client := &http.Client{Timeout: time.Duration(15 * time.Second)}
19 resp, clientErr := client.Do(req)
20 defer resp.Body.Close()
21
22 return clientErr
23}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。