on 2024 Aug 08 4:30 AM
Hi - We have a scenario on C4C where we try to execute an OData Read Query via BTP-IS. It's a custom IFlow we have created. We have an instance where if our filter for ID is not existing. For example, we are executing a search for Ticket using ID 12345 but that ticket no longer exist (maybe deleted or archived), our CPI monitoring is throwing a 404 error with the following information:
HTTP/1.1 404 Not Found
Content-Length: 240
c4c-odata-response-time: 416 ms
<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code/><message xml:lang="en">The server has not found any resource matching the Data Services Request URI</message></error>
Is there a way to bypass/ignore this so that it will not show as an error when monitoring our integration?
Thanks in advance!
Marc
To handle a `404 Not Found` response in SAP Cloud Integration (SAP CPI/BTP-IS) without it being marked as an error, you can take the following steps:
### 1. **Exception Subprocess**:
- Use an exception subprocess in your integration flow to catch the `404 Not Found` response.
- You can configure the exception subprocess to handle specific HTTP status codes, such as `404`.
### **Steps**:
1. **Add an Exception Subprocess**:
- Drag an "Exception Subprocess" into your integration flow.
- This subprocess will catch any exceptions that occur in the main process, including HTTP status codes like `404`.
2. **Use a Router to Filter HTTP Status Code**:
- Inside the exception subprocess, use a `Router` to check the HTTP status code.
- You can route based on `CamelHttpResponseCode` to handle the `404` error specifically.
- Example Expression:
```
${header.CamelHttpResponseCode} == '404'
```
3. **Handle the `404` Response**:
- Inside the route that handles the `404` status, you can add steps to manage the response gracefully.
- You might log the error, set a specific message body, or even create a custom response to pass along to the next steps in the integration flow.
- To prevent the `404` error from being treated as a failure, you can end the subprocess with an "End Message" step, which will bypass the error.
4. **Continue the Main Flow**:
- After handling the `404` in the exception subprocess, your main integration flow will continue without marking the overall process as failed.
### 2. **Using Content Modifier**:
- Alternatively, if you want to treat the `404` response as a successful operation, you can use a Content Modifier or Groovy Script to modify the response message and prevent CPI from treating it as an error.
- Example Groovy Script:
```groovy
if (message.getHeader("CamelHttpResponseCode") == 404) {
message.setBody("<error><message>No Data Found</message></error>")
message.setHeader("CamelHttpResponseCode", 200)
}
return message
```
This script changes the response code to `200` and replaces the message body, which prevents the monitoring from showing the request as an error.
### 3. **Adjusting Logging and Monitoring**:
- You can also configure the logging and monitoring settings in SAP CPI to control how certain HTTP status codes are reported. However, this is more about customizing the integration flow behavior than changing the fundamental logging behavior.
By implementing these strategies, your integration flow will handle `404 Not Found` responses more gracefully, and they will not appear as errors in the monitoring.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.