Skip to Content

How to call a Media File(PDF) in odata service ( form backend to frontend in sapui5

Oct 11, 2017 at 06:19 AM


avatar image

I have been working on the SAPUI5 and I try to get a PDF File from backend when we test it in the SAP Gateway Client "EntitySet()/$value" it's working

~status_code 200

~status_reason OK

but in button press function the code gives an error.

Cannot read property 'body' of undefined

My button code :

function() {

var value = this.getView().byId("inputValue").getValue();

var sRead = "/PrintProcessSet(Tknum='" + value + "')/$value";

var html = new sap.ui.core.HTML();

var oModel = this.getView().getModel();, {

success: function(oData, oResponse) {

var response = oResponse.requestUri;

html.setContent("<iframe src=" + response + " width='700' height='700'></iframe>");

var windows ="", "My PDF", " width='700' height='700'");





error: function() {

alert("Read failed");




We get the Following error

Failed to load resource: the server responded with a status of 404 (Not Found)

1022 2017-10-11 11:41:58.602000 [extended_runnable_file.html] The following problem occurred: no handler for data - O @ Q.fatal @ r._handleError @ VM63:2741 r._processError @ VM63:2734 v @ VM63:2726 w @ VM63:2726 v @ VM63:2723 (anonymous) @ VM63:2790 (anonymous) @ datajs.js:17 p9 @ datajs.js:17 datajs.js:17

Uncaught TypeError: Cannot read property 'body' of undefined

at constructor.r._createEventInfo (eval at evalModuleStr (, <anonymous>:2683:1013)

at constructor.r._processSuccess (eval at evalModuleStr (, <anonymous>:2733:1605)

at w (eval at evalModuleStr (, <anonymous>:2726:831)

at v (eval at evalModuleStr (, <anonymous>:2723:122)

at eval (eval at evalModuleStr (, <anonymous>:2790:272)

at eval (datajs.js:17) at XMLHttpRequest.p9 (datajs.js:17)

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

VIPLOVE KHUSHALANI Oct 11, 2017 at 07:38 AM
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Viplove Khushalani,

I have checked the blog and also added my Question, I have followed the same steps but I get this issue.

Thanks for your help

Sabari .

manik saluja Dec 12, 2017 at 08:39 AM

are you able to solve this issue?


Manik Saluja

10 |10000 characters needed characters left characters exceeded
Yen Shen, Ben Lim 4 days ago


I'm having the same issues. Does this resolved?



Show 8 Share
10 |10000 characters needed characters left characters exceeded

Hello Yen Shen,

check out this link

i think there is no need of method for pdf viewer

just you have to set the url for iframe itself

<html:iframe id="frameId" src=""> </html:iframe>

this.getView().byId(frameId).setSrc("Place ur URI here");



Venkatachala C.K

Hi @Venkatachala C.K,

I've checked this controller. However, I need to display my pdf when using mobile device. This controller only support for desktop mode.




Yen Shen, Ben Lim

In mobile it is not possible to view it seems, so better to download the file and view it.

Venkatachala C.K

If this case, can we conclude using mobile, we are not able to display PDF view?

Yen Shen, Ben Lim

May be Yes, because in the past even i have faced this problem and finally i told them using Mobile its not possible to view PDF until unless it is downloaded.


The behavior of media stream is controlled by the content disposition header set in the response header. You should check what value is set in the Read_Stream/Get_Stream method. To enable opening in browser tab you need to set it as inline and properly set the mime type based on file attributes.


Hi Maskara,

I've confirmed it's not about get_stream method issue. The call from odata was success from backend.

I've tried to insert a hard coded pdf url value in iframe, it's not able to load the pdf in my app in browser mode. My PDF is able to display in pdf view controller in desktop mode as suggestion by Venkatachala C.K. PDFViewer

The current issue is how am I able to display my PDF in mobile mode.

Yen Shen, Ben Lim

Thanks Ben, so basically you have set the correct content headers but still it's not working in mobile. Will wait for solution.