MuleSoft · HTTP Connector
HTTP:UNAUTHORIZED
Short answer
HTTP:UNAUTHORIZED means the server rejected the HTTP Request operation because authentication failed or was not provided (HTTP 401). Send the credentials the server expects, and handle the error type if a rejected call is something the flow should survive.
VerifiedLast verified
01Error text
Error type: HTTP:UNAUTHORIZED02Likely causes
- Authentication failed: the credentials sent with the request were not accepted by the server.
- Authentication was not provided: the request reached the server without the credentials it requires.
- For OAuth 2.0 configurations, no access token has been obtained yet. The docs list the related message
No access token found. Verify that you have authenticated before trying to execute an operation to the API.
03How to fix it
- Confirm that the HTTP Request configuration sends the authentication the server expects, and that the credential values are current for this environment.
- Turn on HTTP wire logging to see the exact request and response: in
log4j2.xml, enable the loggerorg.mule.service.http.impl.service.HttpMessageLoggeratDEBUGlevel. Check that the authentication header is present in the outgoing request. - If you use OAuth 2.0 and see the
No access token foundmessage, call the authorization URL at least once so a token exists, or store the token in an Object Store and refresh it. - Handle the failure with an error handler of type
HTTP:UNAUTHORIZED. Its parent type isMULE:CLIENT_SECURITY, which matches security errors produced by an external system.
04Official documentation
→Related errors
- HTTP:FORBIDDENHTTP:FORBIDDEN means the server refused to return the resource because the client does not have access rights to it (HTTP 403). The credentials were sent, so fix the permissions of the identity behind them on the target system.
- HTTP:BAD_REQUESTHTTP:BAD_REQUEST means the server could not understand the request the HTTP Request operation sent because its syntax was invalid (HTTP 400). Log the outgoing request, compare it with what the server expects, and correct the body, headers or parameters.
- HTTP:NOT_FOUNDHTTP:NOT_FOUND means the HTTP Request operation received a 404 response because the server could not find the requested resource. Check the URL shown in the error description, then correct the request or handle the error type in an error handler.
Test every fix in a non-production environment before you apply it to production. See how entries are verified.
More for MuleSoft work:Open MuleSoft jobsMuleSoft rates and salariesHire a senior MuleSoft developer