create jira issue via rest and javascript, jquery, http 405 method not allowed

simonmeier December 14, 2012
I want to create a jira isse using the rest api and jquery. But with this code I always get a HTTP 405 Method not allowed error.
It seems that jsonp is not allowed. Is there a way to create an issue using javascript?


function make_base_auth(user, password) { var tok = user + ':' + password; var hash = btoa(tok); return "Basic " + hash; } function createJiraIssue() { var datos = { "fields": { "project": { "key": "HELP" }, "summary": "Test Ticket", "description": "Creating of an issue using project keys and issue type names using the REST API", "issuetype": { "name": "Bug" }, "assignee": { "name": "sim" } } }; var parameters = JSON.stringify(datos); var req = $.ajax({ url: 'https://xxx.jira.com/rest/api/2/issue/', type: "POST", data: parameters, contentType: 'application/json', dataType: 'jsonp', async: false, processData: false, beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', make_base_auth(user, password)); }, error: function (errmsg) { alert('error ocured:' + errmsg.responseText); }, success: function (text) { alert(text); }, }); }

 

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Sven Lecherbonnier June 19, 2013

Hi Simon, Kieran,

Are you still blocking on this issue ?

I'm looking for a solution to create an issue from JQUERY ?

Do you have a very sample code ?

Thanks for your help !

Regards,

Sven.

0 votes
Sven Lecherbonnier June 18, 2013

Hi Simon, Kieran,

Are you still blocking on this issue ?

I'm looking for a solution to create an issue from JQUERY ?

Do you have a very sample code ?

Thanks for your help !

Regards,

Sven.

Kieran Sheehan June 19, 2013

Hi Sven,

It works for me anyway :)

To create an issue, see here :

https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue

I've not tried it - I'm just querying existing data, but it should work.

Sven Lecherbonnier June 19, 2013

Cool !

I used REST through JAVA or PHP.

I have got some problem to use it with JAVASCRIPT/JQUERY.

Do you have some very simple sample code about it ?

Thanks by Advance !

0 votes
Kieran Sheehan January 13, 2013

I'm no expert bu you might need:

instead of -

xhr.setRequestHeader('Authorization', make_base_auth(user, password));

use -

xhr.setRequestHeader('Authorization', 'basic: '+make_base_auth(user, password));

0 votes
simonmeier December 17, 2012

i guess it has to be dataType: 'json',
but still i end up in the error: code block

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events