Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnmarshalPayload for errors? #140

Open
tisba opened this issue May 4, 2018 · 4 comments
Open

UnmarshalPayload for errors? #140

tisba opened this issue May 4, 2018 · 4 comments

Comments

@tisba
Copy link

tisba commented May 4, 2018

I'm trying to figure out how I am supposed to use jsonapi to unmarshal an error response I got from my API:

{
  "message": "User could not be updated",
  "errors": [
    {
      "code": "E23",
      "source": {
        "pointer": "/data/attributes/email"
      },
      "title": "Error Title",
      "detail": "More detailed error message",
      "meta": {
        // object with meta data
      }
    }
  ]
}

I first tried

item := new(jsonapi.ErrorsPayload)
err = jsonapi.UnmarshalPayload(errorBody, item)

but this does not work, because jsonapi.UnmarshalPayload does expect a data attribute (https://github.com/google/jsonapi/blob/master/request.go#L71). At this point I got lost and I'm not sure how this is supposed to be used...

@chriswalz
Copy link

I have this problem as well :(

thilonel added a commit to thilonel/jsonapi that referenced this issue Jul 3, 2019
@thilonel
Copy link

thilonel commented Jul 20, 2019

@tisba @chriswalz I have submitted a PR. If you take a look at it you'll see how to do this yourself - it's quite simple - yet I think it'd be nice if they merged it.

@vivian-yamamoto-vt
Copy link

Any word on this getting merged in?

@priyanka-dh
Copy link

Still no update on this PR?

In the meanwhile has everyone added their own wrappers to unmarshal error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants