Hi,
I'm trying to call RestFull API and wants to send the credentials using headers. It works perfectly fine for android and using POSTMAN or Advanced Rest Client. but the app crashes in iOS with no errors in console.
xhr.setRequestHeader("Username", Username); xhr.setRequestHeader("Password", Password);Is there any other way to pass the parameters using headers in iOS?
Titanium SDK = 3.5.0
iOS target = 7.1 and 8.1
REST API with POST method.
my function is as follows
function executeRequest(Username, Password, successCallback, errorCallback) { Ti.API.info("network : " + Username + " : " + Password + " : " + Password); var xhr = Titanium.Network.createHTTPClient(); xhr.open("POST", baseUrl); xhr.onload = function() { if (this.status == '200') { if (this.readyState == 4) { if (OS_IOS) { Titanium.API.info("success headers : " + JSON.stringify(xhr.getResponseHeaders())); } else { Titanium.API.info("success headers : " + JSON.stringify(xhr.getAllResponseHeaders())); } xhr = null; successCallback(this.responseText); } else { //alert('HTTP Ready State != 4'); } } else { Titanium.API.error("Error =>" + this.response); xhr = null; errorCallback(this.responseText); } }; xhr.onerror = function(e) { errorCallback(e); xhr = null; Titanium.API.info(JSON.stringify(e)); if (OS_IOS) { Titanium.API.info("success headers : " + JSON.stringify(xhr.getResponseHeaders())); } else { Titanium.API.info("success headers : " + JSON.stringify(xhr.getAllResponseHeaders())); } }; xhr.timeout = 50000; xhr.setRequestHeader("Username", Username); xhr.setRequestHeader("Password", Password); xhr.send(); //return xhr; };Thanks in Advance.