Troubleshooting the REST API


To understand errors from the REST API, examine the status code of the response along with the response body if present. If that does not help, and you have access to the appliance's logs, look at the log file for the REST API subsystem.


Issues with authentication

An error 401 indicates that you could not be authenticated by using the token expected in the HTTP "Authorization" header. Several reasons could cause this problem:

  • The "Authorization" header itself is missing or invalid.
  • The token is missing from the header or is invalid.
  • The token has expired. Note that tokens only expire if they are generated from the /api/token endpoint (as opposed to being generated in the user interface). In this case, generate a new one with another call to the same endpoint. If you are using the Swagger UI, the interaction with /api/token is hidden from you. To trigger another call to the endpoint, refresh the Swagger UI and enter your username and password again.
  • The user that owns the token has been deactivated or deleted.

You cannot generate a token for the System user. The System user cannot be used to access the API by design, which is to encourage more secure use of permissioning in the system. Additionally, if the System user's API token is revealed, there is no way to delete this user.

Issues with connection to the API at all over HTTPS

By default, the REST API is only accessible over HTTPS. However, if you have not configured HTTPS, requests for any endpoint will fail to connect:

curl https://appliance/api/about

curl: (7) couldn't connect to host

Either configure HTTPS or enable API access over HTTP, although HTTP is only recommended for testing.

Timeout while using the API to bulk update ETL configurations

When you use the API to update configuration of multiple ETLs, the "504 Gateway Time-out" error occurs.

Resolution

Create a script that includes the following API calls:

  1. Retrieve a list of ETLs that you want to update:
    post /opt/api/v1/backend/etls/
    Add a filter to specify a search criteria. 

    Example filter
    {
      "entity_catalog_id": "6",
     "etl_name": "DRCOZ%",
     "etl_description": "%prod%",
      "properties_filter_operator": "OR",
      "properties_filter": {
     "general.log.level": "10"
      }
  2. Use the ETL ID obtained in the response to update each ETL with the following API call:

    post /opt/api/v1/backend/etls/<etl-id>/configuration/update

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Helix Continuous Optimization 24.2