iGlow / Blog / statusCode: 401

SAP CPI error

HTTP operation failed invoking ... with statusCode: 401

Short answer: This error means the receiver answered but refused your login. It usually happens when the credential alias, the authentication type or the OAuth token settings in the HTTP receiver channel are wrong, or the token expired. To fix it, correct the credentials in Security Material and test the call outside CPI.

The problem

The call reaches the receiver and comes back refused. The log says only "statusCode: 401" and a URL. Is the password wrong, the alias wrong, the token expired or the scope off? You end up testing in a REST client, reading the channel settings and guessing which credential artifact the channel really uses.

What does statusCode: 401 mean?

HTTP status 401 means Unauthorized. CPI reached the receiver, the TLS handshake worked, and the receiver read the request. It then said it does not accept the identity that came with it. The text shows the URL that was called and the status code.

Full text in the log: org.apache.camel.component.ahc.AhcOperationFailedException: HTTP operation failed invoking https://api.example.com/orders with statusCode: 401

Why does it happen?

The most common cause comes first.

How do I fix statusCode: 401 in SAP CPI?

  1. Open the failed message in Monitor Message Processing and read the response body. Many servers explain the refusal.
  2. Repeat the call from a REST client with the same credentials. If it fails there too, the credentials are wrong.
  3. Check Authentication and Credential Name in the HTTP receiver channel.
  4. Update the artifact under Manage Security > Security Material and deploy it. Resend the message.

How do I confirm it is fixed?

Resend the message. The status turns Completed and the receiver step shows a 2xx response in the log.

Which adapter or step causes it?

The HTTP receiver adapter (and others that use HTTP, such as OData). The error appears at the receiver step.

Tips to avoid it next time

Keep one credential artifact per receiver system, and name it after the system, so the alias in the channel is easy to check. Note when passwords expire. With OAuth 2.0, do not copy tokens by hand: let the channel fetch them. If a 401 appears only now and then, think of token expiry before you think of a wrong password. For other receiver codes, see the 404 section in the full error guide.

See all ten in the 10 most common SAP CPI errors and how to fix each for SAP Cloud Integration (SAP Integration Suite).

The easy way: fix a 401 error with iGlow

iGlow is an AI agent for SAP Integration Suite and CPI that runs as a Chrome extension side panel. The hunt above is what the Fix button does for you.

  1. Open the panel. The failed message is listed with a Fix button.
  2. Click Fix. iGlow reads the error, the receiver step, the URL and the response, then explains that the receiver refused the credentials.
  3. Follow the next steps: which alias and authentication type to check in the channel, and which credential artifact to update in Security Material. You make the change, because iGlow never sets a real password for you, and secret values are never shown to the AI.
iGlow panel chat for the demo iFlow Orders_Blog_Demo with a card of 2 failed messages, each with its time, the label Fails until fixed, the start of the HttpResponseException error text and a Fix button
Failed messages in the iGlow panel: time, error text, a hint that the message fails until fixed, and a Fix button. (This example shows a different error.)
The Fix flow, shown on another error (a null amount in a Groovy mapping script in the demo iFlow Invoice_S4_to_Ariba): click Fix, read the cause, review the patch. In the clip the patch is rejected, so nothing changes. For a 401, iGlow gives next steps and does not edit credentials.

Nothing is saved or deployed without your click, and tenants tagged PRD are never changed. See the Fix failed messages guide. Add iGlow to Chrome.

Questions

What does HTTP operation failed invoking with statusCode 401 mean?

The receiver server rejected the credentials CPI sent. The connection itself worked.

How do I fix statusCode 401 in SAP CPI?

Check the credential alias and authentication type in the receiver channel, test the same credentials in a REST client, then update the credential in Security Material.

Which adapter or step causes statusCode 401?

The HTTP receiver adapter, or any receiver adapter that calls an HTTP API, such as OData.

More from the blog and guides