I am trying to access an API that requires authentication. This is the code that i am using but i keep getting a 405 Method Not Allowed error. Any thoughts? (my username and password are correct)
function basic_auth(user, pass){
var tok = user + ':' + pass;
var hash = $.base64.encode(tok);
return "Basic " + hash;
}
var auth = basic_auth('username','password');
var releaseName1 = "11.6.3";
var releaseName2 = "11.6.3 Confirmed";
$.ajax({
type: "GET",
url: "https://www10.v1host.com/Company/rest-1.v1/Data/Story?sel=Description,Number,Name,Timebox.Name,Parent,AssetState&where=Custom_Release2.Name='"+releaseName1+"','"+releaseName2+"';AssetState='64'",
beforeSend: function(xhr){
xhr.setRequestHeader('Authorization', auth);
},
dataType: "xml",
async: false,
success: parseXml
});
function parseXml(xml){
$(xml).find("item");
}
You can't make javascript/Ajax calls across domains (without some serious kludging). What we've done for this in the past is to create a local jsp proxy that we call with our javascript but is just a pass-through to the remote URL.
Here is some example JSP code that is close to what I've used to hit a SOLR instance returning JSON.
try to change your datatype to "jsonp" is you are trying to send a cross domain request