Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

UnmarshalPayload for errors? #140

Open

Description

@tisba

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...

Activity

  1. chriswalz commented on May 30, 2019

    @chriswalz

    I have this problem as well :(

  2. thilonel commented on Jul 20, 2019

    @thilonel

    @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.

  3. vivian-yamamoto-vt commented on Aug 12, 2021

    @vivian-yamamoto-vt

    Any word on this getting merged in?

  4. priyanka-dh commented on Mar 9, 2022

    @priyanka-dh

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions