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)