Sentinel

Responses

All about the resonses you could receive and how to interpret them

Status Codes

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

The API does not clarify every issue with status codes to attempt to avoid revealing user information. For example there is no clarification if the username or password is incorrect or if the user exist. You'll be met with status code 400 irrespectively. If you follow Status codes && Errors you will have all the information you need. Common Codes:

  • 200: Success
  • 400: Bad Request (Typically indicates an issue with the client's request, such as invalid syntax, missing parameters, or invalid data.)
  • 3xx: Redirection (e.g., you might be using HTTP and your client isn't configured to follow redirects to HTTPS).
  • 500: Internal Server Error (API issue)

Errors

For 400/500 status codes, the API generally returns a JSON error body with the following structure. The user_id in an error response may be a zero UUID (e.g., 00000000-0000-0000-0000-000000000000) if the user cannot be identified or is not relevant to the error.

{
  "user_id": "00000000-0000-0000-0000-000000000000",
  "error": "Could not login user"
}

How do you equate for this in your struct? Using login as an example: Either you check the status code and then unmarshal the body accordingly.

if statuscode = 200 / 201

interface IloginResponse {
  access_token: string;
  refresh_token: string;
  expires_time: number;
  user_id: string;
  session_id: string;
}

if 400 =< statuscode =< 599

interface ILoginResponse {
  user_id: string;
  error: string;
}

Or you unmarshal the whole struct regardless

interface ILoginResponse {
  access_token: string;
  refresh_token: string;
  expires_time: number;
  user_id: string;
  session_id: string;
  error: string;
}

When using a combined struct, check for the presence of 'error'. If 'error' is present, fields like 'access_token' will likely be absent or null.

Troubleshooting steps

  1. Check response code

  2. Check error in response body

  3. If the response code is 400 and it is not clear what is causing the issue please contact oneclub

  4. On error 500 this is a issue with the API itself and should have been logged by the API