如何使用golang发送帖子,替换为curl命令

There is my code :

The error is:

stream error: stream ID 1; REFUSED_STREAM

But the curl command is Ok:

curl -H "Content-type: application/json" -X POST -d '{"skip_mobile":false,"selected_website":[],"basic_info":{"name":"王凯","id_card_num":"410881199210130778","cell_phone_num":"18817953402"}}'  https://www.juxinli.com/orgApi/rest/v2/applications/yiqime

I want to know why

I can give you a simple tip. Just try to run your code using POSTMAN Tool of chrome. It's an extension. Install it and send request using that and you can generate exact code in any language for that request.

enter image description here

There is an issue with Go connecting to nginx over HTTP2.

more details here: https://github.com/golang/go/issues/17066

In versions of Go after 1.6, HTTP2 is enabled by default. Disabling it should solve this.

http.DefaultClient.Transport = &http.Transport{
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
}
resp, err := http.DefaultClient.Do(req)