diff --git a/request.go b/request.go index d42b42e8..4010668b 100644 --- a/request.go +++ b/request.go @@ -3,6 +3,7 @@ package goinsta import ( "bytes" "encoding/json" + "errors" "fmt" "io/ioutil" "math/rand" @@ -115,7 +116,10 @@ func (insta *Instagram) sendRequest(o *reqOptions) (body []byte, err error) { body, err = ioutil.ReadAll(resp.Body) if err == nil { err = isError(resp.StatusCode, body) + } else if resp.StatusCode == http.StatusBadRequest { + err = isError(resp.StatusCode, body) } + return body, err } @@ -136,6 +140,8 @@ func isError(code int, body []byte) (err error) { if ierr.Message == "challenge_required" { return ierr.ChallengeError + } else if ierr.Message == "feedback_required" { + return errors.New("fail: " + ierr.FeedbackMessage) } if err == nil && ierr.Message != "" { diff --git a/types.go b/types.go index 65547fcc..3a05c416 100644 --- a/types.go +++ b/types.go @@ -52,9 +52,10 @@ func (e ErrorN) Error() string { // Error400 is error returned by HTTP 400 status code. type Error400 struct { ChallengeError - Action string `json:"action"` - StatusCode string `json:"status_code"` - Payload struct { + FeedbackMessage string `json:"feedback_message"` + Action string `json:"action"` + StatusCode string `json:"status_code"` + Payload struct { ClientContext string `json:"client_context"` Message string `json:"message"` } `json:"payload"`