This is a post to place typical errors and solutions to make them searchable to Bing. Please feel free to add your own examples as and when you come across something that may be useful to others.
Error:
When just running a general API call (just GET on companies), postman shows this error:
"error": {
"code": "Authentication_InvalidCredentials",
"message": "Web service call failed because user could not be authenticated or authorized. CorrelationId: 0e82377d-b2af-437d-be1d-71c99ea29421."
}
This error is a generic "something went wrong in authentication"-error, so if possible try to get more details, either via telemetry, or for OnPrem, if you get this warning in the Applicatoin Log:
Message User signed in with the following information: user type=Normal user, entitlement set Ids=, authorization status=Failed, guest user=False, failure reason=A user successfully authenticated in Azure Active Directory but the user does not have any entitlements in Business Central.
Then one possible option is that the role-section is missing in the token. Decode the token for example on JSON Web Tokens - jwt.io and check that the token contains a section like this:
"roles": [
"Automation.ReadWrite.All",
"app_access",
"API.ReadWrite.All"
]
======