title: Golang HTTP Basic Auth
body: <p>I am new in golang.</p>
  
  <p>I am trying to call JIRA rest api with basic auth, but getting following error</p>
  
  <pre><code>&amp;{401 Unauthorized 401 HTTP/2.0 2 0
  map[X-Content-Type-Options:[nosniff]
  Set-Cookie:[JSESSIONID=E08620; Path=/;
  Secure; HttpOnly studio.crowd.tokenkey="";
  Domain=.test.atlassian.net; Expires=Thu, 01-Jan-1970 00:00:10
  GMT; Path=/; Secure; HttpOnly studio.crowd.tokenkey="";
  Domain=.test.atlassian.net; Expires=Thu, 01-Jan-1970 00:00:10
  GMT; Path=/; Secure; HttpOnly] Server:[nginx] Date:[Mon, 09 Jan 2017
  05:18:29 GMT] Content-Type:[text/html;charset=UTF-8]
  X-Arequestid:[648x20759x1] X-Seraph-Loginreason:[AUTHENTICATED_FAILED]
  Www-Authenticate:[OAuth
  realm="https%3A%2F%2Ftest.atlassian.net"]] {0xc42039b900} -1 []
  false false map[] 0xc4200ce0f0 0xc4202b0420}
  </code></pre>
  
  <p>My code is </p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "log"
      "net/http"
  )
  
  const (
      USERNAME = ""
      PASSWORD = ""
      URL      = "https://test.atlassian.net/rest/api/2/issue/SLUB-7194"
  )
  
  func main() {
      req, err := http.NewRequest("GET", URL, nil)
      req.SetBasicAuth(USERNAME, PASSWORD)
  
      req.Header.Set("Accept", "application/json")
      req.Header.Set("Content-Type", "application/json")
  
      cli := &amp;http.Client{}
      resp, err := cli.Do(req)
  
      if err != nil {
          log.Fatal(err)
      }
  
      fmt.Println(resp);
  }
  </code></pre>
  
  <p>Am I doing something wrong?</p>
  
  <p>Thanks in advance</p>