title: How do I send a JSON string in a POST request in Go
body: <p>I tried working with Apiary and made a universal template to send JSON to mock server and have this code:</p>
  
  <pre><code>package main
  
  import (
      "encoding/json"
      "fmt"
      "github.com/jmcvetta/napping"
      "log"
      "net/http"
  )
  
  func main() {
      url := "http://restapi3.apiary.io/notes"
      fmt.Println("URL:&gt;", url)
  
      s := napping.Session{}
      h := &amp;http.Header{}
      h.Set("X-Custom-Header", "myvalue")
      s.Header = h
  
      var jsonStr = []byte(`
  {
      "title": "Buy cheese and bread for breakfast."
  }`)
  
      var data map[string]json.RawMessage
      err := json.Unmarshal(jsonStr, &amp;data)
      if err != nil {
          fmt.Println(err)
      }
  
      resp, err := s.Post(url, &amp;data, nil, nil)
      if err != nil {
          log.Fatal(err)
      }
      fmt.Println("response Status:", resp.Status())
      fmt.Println("response Headers:", resp.HttpResponse().Header)
      fmt.Println("response Body:", resp.RawText())
  
  }
  </code></pre>
  
  <p>This code doesn't send JSON properly, but I don't know why. The JSON string can be different in every call. I can't use <code>Struct</code> for this.</p>