ReferenceProperty status

Error handling

The Lodging Partner GraphQL API responses can contain errors that occur during the different phases of a request (authentication, validation, schema generation, and execution) as well as internal system errors. The following describes the payload of an HTTP GraphQL response:

1{
2 data: { ... },
3 errors: [] // only present if an error occurs
4}

The semantics of the response format as well as more details about the error object content (returned in the errors array) are described in full detail in the GraphQL error spec.

HTTP status codes

These status codes are used in response to the HTTP request:

CodeDescription
200HTTP request was successful. However, GraphQL execution errors are reported using this status code. The response will include a JSON response payload that follows the error format described below.
400Server cannot process the request because of an issue with the request. The response will include a JSON response payload that follows the error format described below.
401Unauthorized. The API cannot fulfill the request because the client does not have the necessary scopes to access the capability or because the access token is missing, invalid, or expired. Response does not contain a response body.
403Forbidden. The server refuses to authorize it because the partner does not have the necessary scopes to call the specific capability, is not allowed to access a specific resource (permission check error), or is not allowed to upload/download the files. The response will include a JSON response payload that follows the error format described below.
404Not found. The requested file could not be found. The response will include a JSON response payload that indicates the file ID.
429User has sent too many requests in a given amount of time ("rate limiting"). Response does not contain a response body.
500An internal error occurred. Response may contain a JSON response payload depending on the type of error or where it originates in the application stack.

Error classes

If an error is thrown before or during the following, it is associated with the GraphQL request:

  • transport of the HTTP request to the server hosting the GraphQL endpoint
  • the request phase of the GraphQL lifecycle
  • the parse phase of the GraphQL lifecycle
  • the validate phase of the GraphQL lifecycle

If an error is during the execute phase of the GraphQL lifecycle, it is associated with the GraphQL execution.

In either case, an error object is returned to the requester. An HTTP or GraphQL request error results in a non-200 status code, while a GraphQL execution error results in a 200 status code. These error classes are defined as follows:

  • User input error during GraphQL execution

    This occurs when an input or parameter to a resolver was not in an expected form or did meet parameter requirements. The intention of this type of error is to give the user information about what to change or provide. An HTTP status code of 200 is returned. Here is an example of the error object response format:

    1{
    2 "errors": [
    3 {
    4 "message": "Invalid ID. An ID with the IDType of 'Supplier' does not exist or you do not have permission to access it.",
    5 "extensions": {
    6 "context": "53185459",
    7 "code": "BAD_USER_INPUT"
    8 }
    9 }
    10 ],
    11 "data": {
    12 "property": null
    13 }
    14}
  • Authentication error during GraphQL execution

    This occurs when the requesting client needs to be authenticated in order to access the requested data. An HTTP status code of 200 is returned. Here is an example of the error object response format:

    1{
    2 "errors": [
    3 {
    4 "message": "Error occurred while requesting status: Failed to get authorization from Supply Access Management.",
    5 "locations": [
    6 {
    7 "line": 2,
    8 "column": 3
    9 }
    10 ],
    11 "path": ['property'],
    12 "extensions": {
    13 "code": "UNAUTHENTICATED"
    14 }
    15 }
    16 ]
    17}
  • Forbidden error during GraphQL execution

    This type of error occurs when the requesting client is not permitted to access the requested resource or GraphQL data path. An HTTP status code of 403 is returned. Forbidden error messages include the following:

    • Insufficient Permissions
    • Missing Required Scope

    Here is an example of the error object response format:

    1{
    2 "errors": [
    3 {
    4 "message": "You do not have sufficient rights to access the resource you requested.",
    5 "extensions": {
    6 "code": "FORBIDDEN"
    7 }
    8 }
    9 ],
    10 "data": {
    11 "property": null
    12 }
    13}
  • Syntax errors in the GraphQL request

    These occur when the GraphQL operation contains a syntax error. An HTTP status code of 400 is returned. Here is an example of the error object response format:

    1{
    2 "errors": [
    3 {
    4 "message": "Syntax Error: Unexpected Name "}",
    5 "locations": [
    6 {
    7 "line": 1,
    8 "column": 1
    9 }
    10 ],
    11 "extensions": {
    12 "code": "GRAPHQL_PARSE_FAILED"
    13 }
    14 }
    15 ]
    16}
  • Validation errors in the GraphQL request

    This type of error occurs if a request is syntactically invalid or does not adhere to the restrictions defined by the schema, such as if a required argument was not provided. An HTTP status code of 200 is returned. Here is an example of the error object response format:

    1{
    2 "errors": [
    3 {
    4 "message": "Field \"property\" argument \"id\" of type \"String!\" is required, but it was not provided.",
    5 "locations": [
    6 {
    7 "line": 2,
    8 "column": 3
    9 }
    10 ],
    11 "extensions": {
    12 "code": "GRAPHQL_VALIDATION_FAILED"
    13 }
    14 }
    15 ]
    16}
  • Rate limit exceeded

    This type of error occurs when you exceed our rate limit at the resource level. An HTTP status code of 200 is returned. (We recommend that you consider throttling your requests.) Here is an example of the error object response format:

    1{
    2 "errors": [
    3 {
    4 "message": "Too many requests, please try again in 1 seconds.",
    5 "path": [
    6 "addMessage"
    7 ],
    8 "extensions": {
    9 "limit": 5,
    10 "duration": 1,
    11 "code": "RATE_LIMIT_EXCEEDED"
    12 }
    13 }
    14 ]
    15}
  • Unknown or unsupported resource (data source error)

    If a non-existent resource is requested, such as a property that does not exist, an HTTP status code of 200 is returned but the data set is null. Here is an example of the response:

    1{
    2 "errors": [
    3 {
    4 "message": "id: 92tjs932d not found.",
    5 "locations": [
    6 {
    7 "line": 2,
    8 "column": 3
    9 }
    10 ],
    11 "path": [
    12 "property"
    13 ],
    14 "extensions": {
    15 "code": "DATA_SOURCE_ERROR"
    16 }
    17 }
    18 ],
    19 "data": {
    20 "property": null
    21 }
    22}
  • Internal server error during GraphQL execution

    This type of error occurs when an error object is thrown from a resolver, when an error could not automatically be remapped to a known error class, or when an internal server error is thrown from a resolver. An HTTP status code of 200 is returned. Here is an example of the error object response format:

    1{
    2 "errors": [
    3 {
    4 "message": "Cannot read property 'spfm' of null"
    5 "locations": [
    6 {
    7 "line": 2,
    8 "column": 3
    9 }
    10 ]
    11 }
    12 ],
    13 "path": ['property'],
    14 "extensions": {
    15 "code": "INTERNAL_SERVER_ERROR"
    16 }
    17}