Skip to content

UnmarshalPayload for errors? #140

Open
@tisba

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

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