1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-07-17 01:12:24 +02:00

Merge pull request #39 from bidesh/master

Return body untouched if error when creating issue
This commit is contained in:
Andy Grunwald
2016-10-05 15:17:44 +02:00
committed by GitHub

View File

@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"mime/multipart" "mime/multipart"
"net/url" "net/url"
"reflect" "reflect"
@ -506,13 +507,22 @@ func (s *IssueService) Create(issue *Issue) (*Issue, *Response, error) {
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
resp, err := s.client.Do(req, nil)
responseIssue := new(Issue)
resp, err := s.client.Do(req, responseIssue)
if err != nil { if err != nil {
// incase of error return the resp for further inspection
return nil, resp, err return nil, resp, err
} }
responseIssue := new(Issue)
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, resp, fmt.Errorf("Could not read the returned data")
}
err = json.Unmarshal(data, responseIssue)
if err != nil {
return nil, resp, fmt.Errorf("Could not unmarshall the data into struct")
}
return responseIssue, resp, nil return responseIssue, resp, nil
} }