on 05-05-2017 11:45 AM
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() {
$.ajax({
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.
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.
Thanks,
Vikash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please find the code here. Controller code is in the Q. There is no response in the 'Network' tab.
//json model
employee:
[
{address: "xxx",
employeeId: "xxx",
employeeName: "xxx",
jobType: "xxx",
salary: "xxx"
},
...
]
//binding in the view
<Table id="itable" items="{/employee}">
...
<items>
<ColumnListItem>
<cells>
<Text text="{employeeId}"></Text>
<Text text="{employeeName}"></Text>
...
</cells>
</ColumnListItem>
</items>
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.
Thanks,
Vikash
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 ?
regards,
Sushil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
regards,
Nils
i think the error msg is very clear.
are u able to get any data if you put the url in browser?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.