Closed harishthirunahari closed 6 years ago
I am using Iron ajax(polymer 2.0) in my application to invoke an API which should include credentials while making a call.
<iron-ajax id="ajax" url="sample url" method="GET" content-type="application/json" handle-as="json" on-response="handleSuccess" on-error="handleError"> </iron-ajax>
I am calling this ajax in a button click like below
this.$.ajax.withCredentials = true; this.$.ajax.headers['X-Requested-With'] = "XMLHttpRequest"; this.$.ajax.headers['Authorization'] = this.makeHeaders(this.userid, this.password); this.$.ajax.generateRequest();
It is going into error which gives status as 405(method not allowed). The makeHeaders function looks like below
makeHeaders(user, password) { return "Basic " + btoa(user + ":" + password); }
I am using Iron ajax(polymer 2.0) in my application to invoke an API which should include credentials while making a call.
<iron-ajax id="ajax" url="sample url" method="GET" content-type="application/json" handle-as="json" on-response="handleSuccess" on-error="handleError"> </iron-ajax>
I am calling this ajax in a button click like below
It is going into error which gives status as 405(method not allowed). The makeHeaders function looks like below
makeHeaders(user, password) { return "Basic " + btoa(user + ":" + password); }