Troubleshooting the REST API
To start understanding 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 server logs, then look at the log file for the REST API subsystem (setting the log level of the package
com.bmc.bcan.rest to DEBUG temporarily can be useful).
In addition, here is a specific scenario you might encounter.
I keep getting 401 Unauthorized errors back from the API
This indicates that you could not be authenticated using the token expected in "Authorization" header. This could be for a number of reasons:
- Issue: The "Authorization" request header itself is missing or invalid.
Solution: Make sure it starts with the word Bearer.
- Issue: The token is missing from the request header, or is invalid.
Solution: Note that the token may be a negative number, so be sure to include the minus sign.
- Issue: The token has expired.
Solution: Try getting a fresh token. If your application runs into this issue frequently, use the
GET /tokenrequest to keep your token alive.
- Issue: The user that owns the token has been deactivated, disabled, or deleted.
Solution: Contact your system administrator to check the status of the user account in BMC Network Automation and in any external authentication system.