Hey,
I'm trying to create an issue using the REST API. I am able to create issues using basic authentication with Postman.
However using a button that runs an AJAX call gets me a 403.
$(document).ready(function() {
$("button").click(function() {
$.ajax({
type: "POST",
url: "https://mysite.atlassian.net/rest/api/2/issue",
dataType: "JSON",
username: "username",
password: "password",
contentType: "application/json",
data:
JSON.stringify({
"fields": {
"project": {
"key": "TEST"
},
"summary": "LOL work.",
"issuetype": {
"name": "Bug"
},
"description": "One more thing to decide if it really worked"
}
})
});
});
});
The code above uses the same username and password as my Postman call, which produces a ticket. Any thoughts?
Some other details:
Hi Tim,
Could you try this way?
$(document).ready(function() {
$("button").click(function() {
$.ajax({
type: "POST",
url: "https://mysite.atlassian.net/rest/api/2/issue",
dataType: "JSON",
contentType: "application/json",
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password));
xhr.setRequestHeader ("X-Atlassian-Token", "no-check");
},
data:
JSON.stringify({
"fields": {
"project": {
"key": "TEST"
},
"summary": "LOL work.",
"issuetype": {
"name": "Bug"
},
"description": "One more thing to decide if it really worked"
}
})
});
});
});
Regards
Hi Jack,
I have tried above code but I am getting
"from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.