I'm having issues getting the following code to POST/GET information.
Both the POST and GET give a 403 (Forbidden) error.
Using Postman the request sends fine and create the issue no problems.
What am I missing? I can't figure out if it's a problem with Jira not allowing the requests, or my auth header is getting stripped out somewhere on the way before it hits Jira.
But with Postman working fine, it makes me think it's something with my code.
Post Request:
var data = {
"fields": {
"project": {
"key": "test"
},
"summary": "test",
"description": "test",
"issuetype": {
"id": "3"
}
}
}
$.ajax({
url: "/rest/api/2/issue/",
method: "POST",
dataType: "JSON",
Authorization: "Basic eC1tZWdhbjpkYjUtN2ZVdDI2NjI=",
contentType: "application/json",
data : JSON.stringify(data)
}).done(function(response) {
console.log("awesome this works!");
console.log(response);
console.log(data);
}).fail(function(fail) {
console.log("nope, try again");
console.log(fail);
console.log(data);
});
});
Get Request
$.ajax({
type: "GET",
url: "/rest/api/2/issue/TEST-1",
dataType: "JSON",
Authorization: "Basic eC1tZWdhbjpkYjUtN2ZVdDI2NjI=",
error: function(error) {
console.log(error);
console.log(arguments);
},
success: function ()
{
alert('Thanks for your comment!');
}
});