title: Getting http post with basic authentication right in GO
body: <p>I have a standard piece of go http request that I am trying to get right in the code below.</p>
  
  <pre><code>func IssueSearchQuery(conf Config) (string, error) {
  
      tr := &amp;http.Transport{
          TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true},
      }
  
      var client = &amp;http.Client{
          Timeout:   time.Second * 60,
          Transport: tr,
      }
      URL := conf.URL + "/api/search"
      v := url.Values{}
      v.Set("query_expression", "select * from test")
      req, err := http.NewRequest("POST", URL, 
          bytes.NewBufferString(v.Encode()))
  
      req.SetBasicAuth(conf.User, conf.Password)
      resp, err := client.Do(req)
      if err != nil {
          log.Fatal(err)
      }
      bodyText, err := ioutil.ReadAll(resp.Body)
      s := string(bodyText)
      return s, err
  }
  </code></pre>
  
  <p>In the above code, I am connecting to the server, basic authentication works, but the server responds  complaining saying the required <code>query_expression</code> query parameter is missing. If I do <code>curl -u user:pass -d "query_expression=select * from test" --insecure -XPOST 'https://ip:port/api/search'</code> the server responds with the required result. </p>
  
  <p>The code also works if I don't use url.Values{} and instead manually encode my query into the url like <code>URL := conf.URL + "/api/ariel/searches?query_expression=select%20*20from%20test"</code></p>
  
  <p>I am not able to figure out what I am doing wrong with my query parameters. Can someone help? Thanks!</p>