It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

403 Forbidden on POST method of /rest/api/2/issue however get works

Ramneek GUPTA Jan 02, 2017

Hello,

 

I am using the /rest/api/2/issue API of JIRA. I am successfully able to use Get for below URL

https://futuregroupb.atlassian.net/rest/api/2/issue/LHEL-24

but i get 403 forbidden error on POST with basic authentication which i used in GET method.

The POST method works absolutely fine on curl command.

 

Please help.

 

Thanks

Ramneek

8 answers

1 accepted

4 votes
Answer accepted
Nic Brough [Adaptavist] Community Leader Jan 02, 2017

If it works with curl, what is different about the call you are making with whatever is failing?

Ramneek GUPTA Jan 02, 2017

Hello,

Only the client is different, i fire the Curl command from Linux command line which works fine, but when try to hit the API using the AJAX jquery call (using the same authenticatio), i get 403 forbidden error

attached is my JS File, i have intentionally hidden the password here

 

Thanks

Ramneek

Nic Brough [Adaptavist] Community Leader Jan 02, 2017

I don't know enough about javascript to help you with that, but it must be the call in that trying to do the wrong thing.

Ives Laaf Jun 22, 2017

What was the solution? I've currently a similar issue in a CORS scenario - so GET's against the API work but a POST to create a new issue throws a 403...

Hari Prasath P Sep 19, 2017 • edited

I too got the same error 403 forbidden error when trying to access rest-api using POST/PUT method and my code was as follows,

AP.require(['request'], function(request) {
request({
url: 'https://mysite.atlassian.net/rest/api/2/issue/XYZ-5',
type: 'POST',
contentType: 'application/json',
data: {
"fields": {"description": "testing"}
},
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(" user : password "));
},
success: function(response) {
alert("success");
},
error: function (response) {
alert('fail... ');
}
});
});

Did you get any idea to fix the 403() status response. How, to overcome this and edit an existing issue using rest api with POST method. 

And also have questioned regarding Edit and Update issues here.

Or if using CURL can fix this error, how to use this code based on CURL code within request.

1 vote
Daniel Kolle Jun 26, 2018

Can you check the scopes object in your atlassian-connect.json file? I ran into this same issue and found out I only had the READ scope by defailt. I added WRITE scope as well and it worked like a champ.

"scopes": [ "READ", "WRITE" ]

Also, be sure to update your script to use the new AP.request method as the one listed above is deprecated. See docs here

 

Hope that helps!

Kumudu Samarakoon Feb 27, 2019

Thanks, Daniel. I got the same error because of this reason. I added WRITE scope and now It works well. 

0 votes
Suparas Jain Jan 02, 2017

Can you please try "data: JSON.stringify(sendInfo)". I am not sure here but you can try.

Ramneek GUPTA Jan 02, 2017

sorry but it gives me the same error

Also the URL i hitting expects a JSON in the request

0 votes
Thiagarajan C Jan 12, 2018

Is anyone having the answers to the questions posted above. I am having the same issue.

Nic Brough [Adaptavist] Community Leader Jan 13, 2018

I'm sure they discovered that they were not providing the right user details.  This is the usual pattern when a discussion about 404's over REST stops with no-one making follow-up comments.

0 votes
dustbin vern Feb 21, 2018

I'm still having this same issue. I don't think user credentials are the issue, as making GET requests, and POST requests via CURL both work fine with the same credentials. Making the call via AJAX for what it's worth. Any ideas?

0 votes
Nilay Mar 08, 2018 • edited

Has anyone solved this issue? I'm also having the same problem. The curl command works completely fine, however when I try POST method with the same credentials and same datas on my code, it returns 403.

0 votes
Lee Alexis Bermejo Apr 02, 2018 • edited

March 2018

This issue also occurs with using `/rest/auth/latest/session`. This is using AP.request to send the AJAX call (so CORS is not a factor).

* POST request with {username, password} json data

* with or without header Basic Auth, JWT auth

 

But the same POST request works with Postman (with only content-type json in the header).

0 votes
Kevin Cassidy I'm New Here Apr 01, 2019

Hi, I'm also having this issue. 

I can make the POST call work in Postman. But when I try to do it as an AJAX call I get a 403 Forbidden error. 

Would be great to hear if someone has solved this issue. 

Nic Brough [Adaptavist] Community Leader Apr 01, 2019

Is the payload of your AJAX call identical to the POST?

Kevin Cassidy I'm New Here Apr 01, 2019

Yep, I even tried copy & pasting directly out of Postman. 

The error just says "403 (Forbidden)". Here's the code below: 

var requestBody = {
"fields": {
"summary": "Kevin Test",
"description": "Description Test",
"project": {
"id": "13104"
},
"issuetype": {
"id": "7"
},
"components": [
{
"id": "20720"
}
],
"customfield_12213": "2019-04-22"
}
}


var settings = {
"async": true,
"crossDomain": true,
"url": "https://corsBypassURL.com/https://jira.corp.docusign.com/rest/api/2/issue",
"method": "POST",
"headers": {
"Authorization": "Basic xxxxx=",
"Content-Type": "application/json",
"cache-control": "no-cache"
},
"data": requestBody
}

$.ajax(settings).done(function (response) {
console.log(response);
});

Adarsh May 16, 2019

Not sure, but you can try passing User-Agent header. 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

2,507 views 6 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you