发出自定义帖子请求时出现400错误的请求

I believe the problem lies in the url values. When I post this to the server, I will a 400 Bad Request: telling me that I need to have an email value. This leads me to believe that either the email value in editForm is getting parsed incorrectly, or the the first_value is, and then "tainting" the rest. I have seen this: Make a URL-encoded POST request using `http.NewRequest(...)` and believe I am doing everything right, but this is throwing me off.

editForm := url.Values{}
editForm.Add("first_name", "supercool")
editForm.Add("email", "wow@example.com")
editForm.Add("username", "foo")

req, err := http.NewRequest(http.MethodPost, urlEndpoint, strings.NewReader(editForm.Encode()))
if err != nil {
    log.Fatalln(err)
}
client := http.Client{}
resp, err := client.Do(req)

I have double checked what the form data is supposed to be called, and I cannot see an error. For reference, this python code will work.

cn = {
    "first_name": "supercool",
    "email": "wow@example.com",
    "username": "foo"
}
r = requests.post(urlEndpoint, data = cn)

You are not sending the content negotiation header.

Content Type

The Content-Type header field specifies the nature of the data in the body of an entity by giving media type and subtype identifiers, and by providing auxiliary information that may be required for certain media types. After the media type and subtype names, the remainder of the header field is simply a set of parameters, specified in an attribute=value notation. The ordering of parameters is not significant.

Here in this case the content is encoded in application/x-www-form-urlencoded so it has to be communicated to the server using Content-Type header

Please add the following before sending the request

 r.Header.Add("Content-Type", "application/x-www-form-urlencoded")