cancel
Showing results for 
Search instead for 
Did you mean: 

UI5 Application , cannot consume data from SAP PO Rest API

former_member331912
Participant
0 Kudos

Hi,

I am calling a rest web service created in SAP PO, from a UI5 app created in NWDS.

The code is as follows:

$.ajax({ url: "http://<server>:<port>/RESTAdapter/checkvendorexistence?vendornumber=<value>?anycode=value",
type: "GET",
crossDomain: true,
//data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function (response) {
var resp = JSON.parse(response);
alert(resp.status);

},

error: function (xhr, status) {

alert("error"); } });

In chrome, I am getting status 200 OK, and in SAP PO monitoring, I am getting the request and response. But the alert i get is of error function. Where am I going wrong?

Any guidance would be useful.

Thanks

former_member338801
Participant

Hi Ather Iqbal Siddiqui,

What tool you are using to develop sap ui5 app? If you use SAP Web Ide full stack then there are better way to consume any service instead of writing $ajax call. Please refer below blog post for the same.

https://blogs.sap.com/2018/07/10/how-to-read-data-using-ajax-call/

Thanks and Regards,

RK

Accepted Solutions (0)

Answers (3)

Answers (3)

junwu
Active Contributor
0 Kudos

no matter it is odata or not,

any ajax call has to conform to that rule

former_member331912
Participant
0 Kudos

I ended up not using AJAX Call.

Thanks for the input.

former_member331912
Participant
0 Kudos

Hi Ram and Jun, thanks for the comments.

I am using Eclipse NWDS for development, and its on premise. I am sending request from localhost to SAP server on premise.

Its not odata service, I am using Rest API published in SAP PI/PO.

junwu
Active Contributor
0 Kudos

you cannot make it, if your ui5 app and the odata service are not in the same server.

you need web dispatcher to help.