OData v4 Model - propagate http-response headers
Why are you proposing this feature?
I've faced issue while attaching fnHttpListener to the freshly created oData v4 model. When requests are failing with any error, it's not being triggered.
How should a possible solution look like?
Possible solution would be to add into sap/ui/model/odata/v4/lib/_Requestor-dbg.js into
_Requestor.prototype.sendRequest function in the .catch following line:
that.oModelInterface.onHttpResponse(_Helper.parseRawHeaders(jqXHR.getAllResponseHeaders()));
This exists for the successfully performed requests but not for errored requests
Are there alternative approaches?
No response
Any further information you would like to share?
No response
Hello @maximkadrov ! Which API are we talking about here? Looks like fnHttpListener is not a public API and _Requestor is clearly a private class, its name even starts with an underscore :-)
Let's take a step back: what is your problem to solve, what do you try to achieve in the end?
I am trying to intercept http-response headers for the oData v4 batch requests, per documentation I've found only dataReceived method, which only contains error object, but not original headers, I would like to obtain somehow one of them
Again, what do you try to achieve in the end? Intercepting a header is just a means to an end, not an end in itself.
@ThomasChadzelek I would like to have a possibility to capture Correlation IDcoming from CAP backend service as x-correlation-id
OK. Let's ask 5x "why?". So why would you like to capture that x-correlation-id header?
@ThomasChadzelek I am trying to display predefined error MessageBox with the details and Correlation ID to shared with the customer support
Are we talking about cases where the backend responds with an error message or even error response? Or is this some success case where you still like to debug stuff?
I am talking about standard backend responses, doesn't matter with error or successfully executed with data, requests contain response headers with either x-request-id or x-correlation-id. Here is the description
In oData v4 model I would like to obtain these headers, is there any way to do it?
This looks like a feature request to me. Our product management has been informed.
Just to chime in here I'd say the main goal is to give the users the tools to provide more meaningful error reports to us. For that reason we'd like to include the correlation, which allows us to better track down the error.
For example, when SAP API Gateway returns a 502 Bad Gateway because the payload exceeds the 10 MB synchronous limit, we can’t (or do not want to for different reasons) always return a meaningful business-level error to the user but we should still be able to make the requests correlation ID available for support and diagnostics.
As SAP solutions don’t agree on a single header name that likely requires access to the headers of failed responses (e.g. utilized headers being x-correlation-id, x-request-id, x-correlationid or x-vcap-request-id.
Another colleague of ours patched sap.ui.model.odata.v4.lib._Helper.ts with:
sap.ui.require(["sap/ui/model/odata/v4/lib/_Helper"], function (_Helper: any) {
const createErrorFn = _Helper.createError;
const createTechnicalDetailsFn = _Helper.createTechnicalDetails;
_Helper.createError = function () {
const oResult = createErrorFn.apply(this, arguments);
oResult.headers = {};
oResult.headers["x-correlation-id"] =
arguments[0].getResponseHeader("x-correlation-id");
oResult.headers["x-correlationid"] =
arguments[0].getResponseHeader("x-correlationid");
oResult.headers["x-request-id"] =
arguments[0].getResponseHeader("x-request-id");
oResult.headers["x-vcap-request-id"] =
arguments[0].getResponseHeader("x-vcap-request-id");
return oResult;
};
_Helper.createTechnicalDetails = function () {
const oTechnicalDetails = createTechnicalDetailsFn.apply(this, arguments);
oTechnicalDetails.headers = arguments[0]["@$ui5.error"].headers ?? {};
return oTechnicalDetails;
};
});
This looks like a feature request to me. Our product management has been informed.
=> FIORITECHE1-9314 has been created by @tsteckenborn to follow up on this.