Somehow below call returns base64 string instead of xml output. I need to decode this to see xml.
// POST
func (u *UserResource) authenticateUser(request *restful.Request, response *restful.Response) {
Api := new(Api)
Api.url = "http://api.com"
usr := new(User)
err := request.ReadEntity(usr)
if err != nil {
response.AddHeader("Content-Type", "application/json")
response.WriteErrorString(http.StatusInternalServerError, err.Error())
return
}
buf := []byte("<api version=\"6.0\"><request>test</request></api>")
r, err := http.Post(Api.url, "text/plain", bytes.NewBuffer(buf))
if err != nil {
response.AddHeader("Content-Type", "plain/text")
response.WriteErrorString(http.StatusInternalServerError, err.Error())
return
}
defer r.Body.Close()
body, err := ioutil.ReadAll(r.Body)
response.WriteHeader(http.StatusCreated)
response.WriteEntity(body)
}
Is there a way to prevent this from happening and have correct xml output?