JIRA authentication via REST/JSON/AJAX

I'm trying to build a page to raise an issue in our JIRA instance that will be hosted on our SharePoint 2013 site, but I'm having trouble geting authenticated to JIRA.

I CAN submit a request via cur using this command:

curl -D- -k -3 -o "result.html" -w HTML -H "Authorization: Basic XXXXXXXXXX" -X POST --data "{\"fields\"....}}}", -H "Content-Type: application/json" https://jira.mycompany.com/jira/rest/api/2/issue/

But when I try to do the same in my page, I keep getting an 'Access Denied' message. I've tried several varitations, but here is my current code:

$.ajax({
        url: "https://jira.mycompany.com/jira/rest/api/2/issue",
	header: {
		Authorization : "Basic XXXXXXXX",
		contentType : "application/json, json; charset=utf-8"
		},
        type: "POST",
        data: {
	"project" : ......

I've tried this on our production (v5.2.5) and our dev (6.0.8) sites with the same results.

I've tried this also, but get the same results:

$.ajax
  ({
    type: "POST",
    url: "https://jira.mycompany.com/jira/rest/auth/1/session",
    dataType: 'json',
    async: false,
    data: '{"username": "username", "password" : "xxxxxx"}',
    success: function (result) {
            switch (result) {
                case true:
                    processResponse(result);
					alert("It worked!");
                    break;
                default:
                    resultDiv.html(result);
            }
        },
	error: function (xhr, ajaxOptions, thrownError) {
        alert(xhr.status);
        alert(thrownError);
    }
});

If someone could get me pointed in the right direction, I would greatly appreciate it!

1 answer

Our JIRA instances are not be any type of proxy servers.
The examples mentioned in the post refer to CURL examples, and as I stated, when using CURL it works just fine.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

121 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you