cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pass Data to AJAX GET method of REST API in SAPUI5

rauf_shaikh
Active Participant
0 Kudos

Hi All,,

I am working on a SAPUi5 application where I need to call GET method of a REST API using AJAX method a pass data to this api call as well.

I have written below code which is producing HTTP 503 Error code, can some please have a look at this code and help.

var mydata = JSON.stringify(payload);
var settings = {
"url": "postidexx_dest/http/Ariba/PReqSubmit"
"method": "GET",
"headers": {
	"Authorization": 'Basic ' + btoa("user123"+':'+"mypassword"),
	"Content-Type": "text/plain",
},
"data": mydata
};

jQuery.ajax(settings).done(function (response) {
	console.log(response);
});

Please check below Google Chrome Network log and help please

Regards,

Rauf

gregorw
Active Contributor
0 Kudos

Hope you don't plan to hardcode username and password. If you are in the BTP environment please use the destination service to securely store the password.

View Entire Topic
mariusobert
Developer Advocate
Developer Advocate
0 Kudos

The request itself is done right so I would say the problem is caused by the settings (wrong url or payload) or that you didn’t define a route (in the xs-app.json) or destination for it.

rauf_shaikh
Active Participant
0 Kudos

Hi Marius,
There was an issue at server side, The API team create a custom header and I passed data in custom header the it worked.

THanks.