func (c *Client) DoWithResponse(method string, path string, val, result interface{}) error {
	data, err := json.Marshal(val)
	if err != nil {
		return errgo.Notef(err, "cannot marshal PUT body")
	}
	req, _ := http.NewRequest(method, "", bytes.NewReader(data))
	req.Header.Set("Content-Type", "application/json")
	resp, err := c.Do(req, path)
	if err != nil {
		return errgo.Mask(err, isAPIError)
	}
	defer resp.Body.Close()
	// Parse the response.
	if err := httprequest.UnmarshalJSONResponse(resp, result); err != nil {
		return errgo.Mask(err)
	}
	return nil
}
// DoWithResponse is more general version of PutWithResponse. It performs
// the given HTTP method on the given charm store path, sending
// val as the JSON request body and unmarshaling the JSON response into result.
DoWithResponse is more general version of PutWithResponse. It performs
the given HTTP method on the given charm store path, sending
val as the JSON request body and unmarshaling the JSON response into result.
// DoWithResponse is more general version of PutWithResponse . It performs // the given HTTP method on the given charm store path sending // val as the JSON request body and unmarshaling the JSON response into result .
func (c *Client) DoWithResponse(method string, path string, val, result interface{}) error {
	data, err := json.Marshal(val)
	if err != nil {
		return errgo.Notef(err, "cannot marshal PUT body")
	}
	req, _ := http.NewRequest(method, "", bytes.NewReader(data))
	req.Header.Set("Content-Type", "application/json")
	resp, err := c.Do(req, path)
	if err != nil {
		return errgo.Mask(err, isAPIError)
	}
	defer resp.Body.Close()
	if err := httprequest.UnmarshalJSONResponse(resp, result); err != nil {
		return errgo.Mask(err)
	}
	return nil
}
func ( c * Client ) DoWithResponse ( method string , path string , val , result interface { } ) error { data , err := json . Marshal ( val ) if err != nil { return errgo . Notef ( err , " " ) } req , _ := http . NewRequest ( method , " " , bytes . NewReader ( data ) ) req . Header . Set ( " " , " " ) resp , err := c . Do ( req , path ) if err != nil { return errgo . Mask ( err , isAPIError ) } defer resp . Body . Close ( ) if err := httprequest . UnmarshalJSONResponse ( resp , result ) ; err != nil { return errgo . Mask ( err ) } return nil }
DoWithResponse is more general version of PutWithResponse.
DoWithResponse is more general version of PutWithResponse .
// Parse the response.