Make Post request with custom header in golang

Hey Guys,
I spend some time reaching that how I must make an HTTP post request with a custom header in golang and with some help from my friends and some googling I found the answer. here I’ll share this code in the playground and I hope this piece of code helps someone.

make it better with johandalabacka Christophe_Meessen comments

1 Like

Hi. I don’t think you must convert the header fields to lowercase


Note also that you should close the body after the ReadAll:

resp, _ := client.Do(r)
if resp != nil {
    defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.