Trying to accomplish a HTTP Post in Go:
Posting to: apiUrl
Payload/Post Body (expected as a json string): postBody
Here is the error I'm getting:
cannot use postBodyJson (type []byte) as type io.Reader in argument to http.Post:
[]byte does not implement io.Reader (missing Read method)
What am I doing wrong?
Code:
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
var postBody = []string{
"http://google.com",
"http://facebook.com",
"http://youtube.com",
"http://yahoo.com",
"http://twitter.com",
"http://live.com",
}
requestUrl := "http://lsapi.seomoz.com/linkscape/url-metrics"
postBodyJson, _ := json.Marshal(postBody)
resp, err := http.Post(requestUrl, "application/json", postBodyJson)
fmt.Println(resp)
}