I found how to send a POST with URL parameters, or how to send a POST with a JSON body, but I do not know how to combine them together (a request with both a URL with parameters, and a JSON body).
The code below (which is not correct) shows the commbination I am looking for. I can use either bytes.NewBuffer(jsonStr) or strings.NewReader(parm.Encode()) but not both.
package main import ( "bytes" "net/http" "net/url" "strings" ) func main() { var jsonStr = []byte(`{"title":"my request"}`) parm := url.Values{} parm.Add("token", "hello") req, err := http.NewRequest("POST", "https://postman-echo.com/post", bytes.NewBuffer(jsonStr), strings.NewReader(parm.Encode())) if err != nil { panic(err) } req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() } How to build a full POST call with all the components?
parmwas used for both the body and the URL (in different examples) - this is where I got it wrong.