I am new to JIRA REST API.I tried using ajax to validate field (JIRA number) but it failed.Can someone help me with this urgently?

I am using the following below code in order to do validation for JIRA number.Howeve it is not working.Please help me-

function restrictToInteger() {
var username = $("#jiraId").val();

function make_base_auth(username) {
var tok = username;
var hash = btoa(tok);
return "Basic " + hash;
}
$.ajax({
type : "PUT",
url : 'https://jira-lpi.al.intraxa:8443/rest/api/2/issue/username',
dataType : 'json',
contentType : 'application/json',
beforeSend : function(xhr) {
xhr.withCredentials = true;
xhr.setRequestHeader('Authorization',
make_base_auth(username));
},
success : function(status,xhr) {
alert('working');
},
error : function(xhr, textStatus, errorThrown) {
console.log(textStatus + " : " + errorThrown);
alert('no data');
}
});

3 answers

1 accepted

There is no such REST method as  PUT "rest/api/2/issue/username". I am not sure what you are trying to do but the closest method is PUT "rest/api/2/issue/{issueIdOrKey}" that updates issue.

Maybe "by validate JIRA number" you mean check for existence of an issue. Then you can use GET /rest/api/2/issue/{issueIdOrKey}.

Hi,

 

Thanks!!! That was by mistake i have written PUT. I tried using GET but not able to validate.

How to include JIRA issue that is being passed from the UI in the url- "rest/api/2/issue/{issueIdOrKey}" .Like,i have passed ACR-1082 from UI ,then how it will attach to the url so the url can become "https://jira-lpi.al.intraxa:8443/rest/api/2/issue/ACR-1082".

And moreover,I am facing below error-

"Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resourse".

 

Thanks,

Sneha

Hi,

Please someone help me.i need to fix this issue asap.

Thanks,

Sneha

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Fadoua M. Boualem
Published yesterday in Trello

Using Trello to manage events

As a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...

447 views 6 7
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