"no handler for data" exception via `ODataModel.read` stream (OData V2)
See original GitHub issueOpenUI5 version: 1.84.20 - lastest Browser/version (+device/version): Chrome Any other tested browsers/devices(OK/FAIL): N/A
Steps to reproduce the problem:
- Prepare one gateway backend service, we can get a media entity via url /sap/opu/odata/ZTEST/TEST_NAME_SRV/TestEntitySet(guid’xxxxxxx’)/$value
- If we use below code to read file content
const oDataModel2 = new sap.ui.model.odata.v2.ODataModel(oDataModel.sServiceUrl)
oDataModel.read(`/TestEntitySet(guid'${eventMsgguidIn}')/$value`, {
context: null,
urlParameters: null,
filters: null,
sorters: null,
success: (OData, response) => {
console.log(response)
},
error: function (error) {
console.log(error)
}
})
there is one exception in console, the success function can’t be called, even the media file is already included in response
The following problem occurred: no handler for data - sap.ui.model.odata.v2.ODataModel
- but if we use
sap.ui.model.odata.ODataModel
class to create oDataModel, it can work fine
I found lots of similar questions in sap community, so is there any official solution for this issue? Thank you so much. https://answers.sap.com/questions/12197085/the-following-error-occurred-no-handler-for-data.html https://answers.sap.com/questions/343789/fiori-exception-no-handler-for-data.html?childToView=13638724
Any other information? (attach screenshot if possible)
Regards, Hao
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Hi @boghyon Hi @pksinsik , Thanks for your patient explanation and great solution. @pksinsik your solution looks so good, unfortunately I can’t change our backend logic easily in this project, so for my case
$value
is necessary.According to this question,
URLHelper.redirect("<...>/TestEntitySet(guid'${eventMsgguidIn}')/$value", true)
can also help this situation.So I can close this issue. Thanks @boghyon and @pksinsik again.
Hi @Crwing, when having the media resource in a property, it should be possible to not de-reference the property as it happens when using $value, e.g. https://services.odata.org/V2/Northwind/Northwind.svc/Employees(1)/Photo?$format=json gives you the resource in a JSON envelope, so you could read and interpret its value, either as JSON or XML. This should be possible using the UI5 model.
Whereas https://services.odata.org/V2/Northwind/Northwind.svc/Employees(1)/Photo/$value gives you the contents of the media resource. This however cannot be read via the ODataModel as the underlying datajs library always expects a certain format.