Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
104
rated 0 times [  108] [ 4]  / answers: 1 / hits: 7997  / 11 Years ago, sat, december 28, 2013, 12:00:00
<html>
<head>
<script src=http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js>
</script>
<script>
$(document).ready(function(){

$.ajax({
type: GET,
dataType: 'jsonp',
url: http://myJira.com/rest/api/2/issue/MA-6614/comment,
username : myusrName,
password : myPwd,
success: function (data) {
console.log( Sample of data:, JSON.stringify(data));

},
error: function (errormessage) {
console.log( errorMessage:, errormessage);
}
});
});


</script>
</head>
<body>
</body>
</html>


While running the above code I am getting SyntaxError: missing ; before statement error.
I read somewhere Access-Control-Allow-Origin should be used to solve problem. But I don't find a good documentation anywhere about how to use with Jira.



UPDATE

The above error I am getting if I have already loggedin in jira. If I logout in jira and then run the above code then getting error NetworkError: 401 Unauthorized - http://myjira.com/rest/api/2/issue/MA-6614/comment?callback=jQuery1102010440085066514837_1388216960965&_=1388216960966



It seems the above code has two problem.
1. It is not able to authenticate in jira.
2. if we already authenticate in jira (that means browser has cookies)and make the request then syntax error is shown because of jsonp.


More From » jquery

 Answers
2

So I got the answer.
Support in jira is revoked for authenticating from javascript. Iitally jsonP was the option but now it is not possible.
We have to do server side authentication of jira.
Example here




https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Basic+Authentication



[#49176] Thursday, December 26, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaceyr

Total Points: 510
Total Questions: 97
Total Answers: 116

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
kaceyr questions
;