403 forbidden error when using POST method to access rest api for Editing existing issue

I want to edit a field of an existing issue using rest api within request. I can acces GET method easily and get the data using rest api, but cannot access PUT/POST method(got 403()). So have added the following code,

AP.request({
type: 'POST',
contentType: 'application/json',
dataType: 'json',
data: {"fields": {"description": "testing"}},
url: 'https://mysite.atlassian.net/rest/api/2/issue/XYZ-5',
beforeSend: function (xhr){
xhr.setRequestHeader('Authorization', 'basic: '+ base_auth(user, password));
},
success: function (response) {
alert("success");
},
error: function (data, status, error) {
alert("failed");
console.log('error', data, status, error);
}
});

function base_auth(user, password)
{
var loginDetail = user + ':' + password;
var tag = btoa(loginDetail);
return "Basic " + tag;
}

 

But, while using this i get the same error 403() not permitted and also beforeSend code does not get hit.

Already, have posted question regarding Edit and Update issue here.

If using CURL code can fix this issue, can you please suggest how to use the CURL code within request with a sample code.

1 answer

1 accepted

Hi Hari,

usually, you don't have to provide authentication headers when you use the AP.request method, see also the docs for this.

It might be the problem that you didn't specify the corresponding scope, you'd need the WRITE scope for this one, see also the docs here.

Cheers,
Matthias

Hi Matthias,

Yes, I have added WRITE option in scopes and got the issue fixed already. Thanks a lot for your response.

Cheers,

Hari

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,316 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot