This must be fairly simple, but I can't work out why, when making an HTTP request with go, the body of the request gets wrapped in an additional set of braces:
package main
import (
"bytes"
"fmt"
"net/http"
)
func main() {
jsonStr := []byte(`{"some":"test","json":"data"}`)
req, _ := http.NewRequest("POST", "http://test.com", bytes.NewBuffer(jsonStr))
fmt.Print(req.Body)
}
This results in:
{{"some":"test","json":"data"}}
In my actual code I'm using the json.Marshal and a struct to generate the byte buffer, but getting the same result. The result is the API rejecting the request (as expected).
How do I prevent the extra braces being added?