Not getting full response body

hi i want to send back the response body , currently i am getting only status back .

			jumbo_rod_url :="some url "
			body := strings.NewReader(string(ctx.Request.Body()))
			fmt.Println("printing body",body)
			req, err := http.NewRequest("POST", jumbo_rod_url,body)

			req.Header.Add("Authorization", "Bearer "+jumbo_token[2])

			req.Header.Add("Content-Type", "application/json")

			if err != nil {

			resp, _ := http.DefaultClient.Do(req)
			defer resp.Body.Close()
			fmt.Printf("%s","final response ",resp)

//response i am geting

                          // {200 OK %!s(int=200) HTTP/1.1 %!s(int=1) %!s(int=1) map[X-Content-//Type-Options:[nosniff] X-Xss-Protection:[1;mode=block] 

//response i need to get as in swagger
“scope”: “/client”,
“id”: {
“member_id”: “”
“access_token”: “”,
“token_type”: “bearer”,
“expires_in”: 3600,
“refresh_token”: “”,
“refresh_expires_in”: 3600


“resp” is not a string. See the examples at

1 Like

hi Jakob,
how can i get the entire body of the response and not just that status ?

You took a look at the examples @calmh linked in his post?

Its there, right in the second example.

respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return errors.New("Read err")
fmt.Printf("%s","final response ",string(respBody))

this would work for string
now you would have to json.Unmarshal to get the data in a desired struct


Thanks , i was able to resolve my issue :slight_smile:

1 Like

Btw ioutil.ReadAll is not a good idea.
Check this

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.