Skip to content

Instantly share code, notes, and snippets.

@ivanauliaa
Last active December 18, 2021 10:22
Show Gist options
  • Save ivanauliaa/c5017cbe1eae15116e1d2eb90ef53a89 to your computer and use it in GitHub Desktop.
Save ivanauliaa/c5017cbe1eae15116e1d2eb90ef53a89 to your computer and use it in GitHub Desktop.
Construct body params (payload) in POST request (GO)
param := url.Values{}
params.Set("id", ID)
payload := bytes.NewBufferString(params.Encode())
request, err := http.NewRequest("POST", baseUrl+"/user", payload)
if err != nil {
return data, err
}
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment