Skip to Content

Consuming REST webservice into SAPUI5 App.

May 05, 2017 at 10:45 AM


avatar image

I am trying to consume REST Web service into my SAPUI5 Application.The webservice response is in JSON format. How do I bind the data coming in my application.

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

// The controller code is as follow :

onInit: function() {


url: "http://localhost:8080/sdnext/doj/webservice/json/employees/",

type: "GET", dataType: "text",

contentType: "text/json",

success: function(data, textStatus, jqXHR) { response = data; },

error: function(xhr, status) { console.log("ERROR"); },

complete: function(xhr, status) {

var oModel = new sap.ui.model.json.JSONModel(); oModel.loadData(response); this.getView().setModel(oModel);

} });

View is in the image attached for data Binding.

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

3 Answers

Jun Wu May 05, 2017 at 01:51 PM

i think the error msg is very clear.

are u able to get any data if you put the url in browser?

10 |10000 characters needed characters left characters exceeded
Sushil Saladi May 08, 2017 at 06:08 AM

Hi Jun Wu,

I am able to get the json data when I enter it in the browser. The webservice is working fine.

I tried to make it work from my hana cloud web IDE but no luck there. Can you suggest any other way I can consume this web service into an SAPUI5 application? Maybe by Eclipse IDE ?



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

the ajax url says you are requesting an service from localhost. is this REST service also available from outside of your network? don't forget that the webide besides in the cloud platform and therefore technicaly the ajax request is send from the cloud platform network to the localhost network.

another option is a CORS error, but normaly the error message would be another.




The REST web service I created and deployed it to my tomcat server , locally. (i.e localhost:xxxx). It is accessible when the tomcat server is on.

Vikash Rakshit May 08, 2017 at 06:48 AM

Hello Sushil,

Could you please show how you are binding your table. Also check in your network tab for the response. If response is coming then there is an issue with table Binding.



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

Please find the code here. Controller code is in the Q. There is no response in the 'Network' tab.

//json model
{address: "xxx",
employeeId: "xxx",
employeeName: "xxx",
jobType: "xxx",
salary: "xxx"

//binding in the view 

<Table id="itable" items="{/employee}">
<Text text="{employeeId}"></Text>
<Text text="{employeeName}"></Text>

Hi Sushil,

If in your employee json model data is coming then you will get the records in your table. Once you gets data from backend , set that data into json model and give a namespace employee.and then set the table with the jsonmodel.

First requirement would be to get the data from the backend system.