Errors

A response from the API has a data field, an errors field, or both. Check errors in every response.

The error format

Each item in errors has a message. Most items also have path and locations. The path names the field that failed.

This response comes from a query that has no token. The failed field is null in data.

A query can partly succeed. In that case data holds the fields that worked, and errors lists the fields that failed. Read both.

If the GraphQL engine finds a problem in the query itself, the response has no data field. The message names the problem. For example:

{
  "data": {
    "attendeesConnection": null
  },
  "errors": [
    {
      "message": "unauthenticated",
      "path": ["attendeesConnection"],
      "locations": { "line": 2, "column": 3 }
    }
  ]
}

A query can partly succeed. In that case data holds the fields that worked, and errors lists the fields that failed. Read both.

If the GraphQL engine finds a problem in the query itself, the response has no data field. The message names the problem. For example:

{
  "errors": [
    {
      "message": "Cannot query field \"noSuchField\" on type \"RootQueryType\".",
      "locations": { "line": 1, "column": 2 }
    }
  ]
}

HTTP status codes

The API answers HTTP 200 when it runs a query or mutation. The response can still hold errors. These other codes exist.

| Code | Cause | Body | | 400 | The request has no query. | {"errors":[{"message":"No query document supplied"}]} | | 401 | The token is not valid or has expired. | {"errors":[{"message":"invalid_token"}]} | | 405 | A mutation came in a GET request. | An errors list. |

To fix a 401, call the login mutation again. Send the login request without an Authorization header. A request that carries the old token gets the same 401. Then use the new token.

Error messages

MessageCauseWhat to do
unauthenticatedThe request has no Authorization header, or the header does not start with Bearer.Send Authorization: Bearer <token>. See Getting started.
Invalid client id or tokenThe login mutation got a client id or client token that does not match an API user.Copy both values again from the page of the API user in the CMS.
Unauthorized gathering idThe event ( gathering in the schema, selected with gatheringId ) does not exist, or the API user cannot reach it.Check the id that you sent. Check that the API user can reach the event.
Unauthorized app idThe app does not exist, or the API user cannot reach it. A restricted API user always gets this error for gatherings and createGathering.Check the value of appId. Use an organization-wide API user.
first cannot exceed 1000 or last cannot exceed 1000The page size is more than 1000.Use a smaller value. See Pagination.

The API gives the same message when an event does not exist and when the API user cannot reach it.

Errors in arguments

The GraphQL engine checks each argument before it runs a query. It rejects a missing required argument and a value of the wrong type. The message names the argument.

See Scalars for the format of each scalar.

Rejected changes

A create, update, or delete mutation can fail after the API accepts the arguments. Touchpoint then returns the error with two fields:

For a record that is not valid, the reason is in message.status.message. Correct the input and send the mutation again.

{
  "data": {
    "createAttendee": null
  },
  "errors": [
    {
      "code": 403,
      "message": {
        "status": {
          "code": 403,
          "message": "Attendee not valid: [\"<reason>\"]"
        },
        "path": ["createAttendee"],
        "locations": { "line": 2, "column": 3 }
      }
    }
  ]
}

This article is a copy of Errors in the Touchpoint API documentation.

Source: https://touchpoint-support.certain.com/hc/en-us/articles/45282691744023-Errors

Published:

Keywords: Errors, GraphQL, HTTP status codes, unauthenticated, Pagination, Getting started