Error Handling in REST Adapter – SAP PI

This blog will show how to do error handling in REST Adapter. The REST adapter supports Custom Error Handling when used as Sender or receiver.

You can use a custom error handling to define how the adapter will react to certain error codes with custom result messages. Besides, you can create error conditions based on the content of the message data.

In this example when PI will have a mapping error, it will send the custom message as a response to the user. This is simple error handling but it should be good to understand the mechanism.

This blog will not cover any ESR or ID configuration but only REST Adapter and how to test.

For ESR/ID steps that are not covered here check the following blogs.

Sender REST Adapter Scenario in SAP PI – Part I

Sync Scenario using REST adapter in SAP PI – Part II

REST Adapter Configuration

This section will cover how to configure error handling in the REST adapter.

Error Handling Tab:

In the sender and receiver channels, you can define up to ten rules. Each rule is independent of the others. The rules are evaluated from top to bottom, and the first rule that matches determines the action to be taken.

As we will be only considering http error code 500.

The configuration will look like below.

error handling in rest adapter

 

Save and Activate.

Testing

Any REST client can be used here for testing.

if you see below response is the custom message from REST adapter which we have typed

REST Adapter

SAP Reference: Custom Error Handling

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.