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); }, }); }
Community moderators have prevented the ability to post new answers.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i guess it has to be dataType:
'json'
,
but still i end up in the error: code block
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.