Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting 403 forbidden when trying to create JIRA issue using AP.Request

Mark Sliwinski August 31, 2020

Hi all,

I'm trying to create a JIRA issue from confluence using the rest API with an AP.Request() call.

I have no problem attempting to create the issue using curl.

curl --request POST --url 'https://XXX.atlassian.net/rest/api/3/issue' --user YYY:ZZZ --header 'Accept: application/json' --header 'Content-Type: application/json' --data '{"fields": {"summary": "Issue Z created", "issuetype": { "id": "10001" }, "project": { "key": "VP" },"description": {"type": "doc","version": 1, "content": [{ "type": "paragraph", "content": [{"text": "This is the description.", "type": "text"}]}]}}}'

 

Below is the AP.Request.

var jdataString = '{"fields": {"summary": "Issue Z created", "issuetype": { "id": "10001" }, "project": { "key": "VP" },"description": {"type": "doc","version": 1, "content": [{ "type": "paragraph", "content": [{"text": "This is the description.", "type": "text"}]}]}}}'
AP.request({
url: '/rest/api/3/issue',
type: 'POST',
headers : {
accept: 'application/json'
},
contentType: 'application/json',
data: jdataString,
})
.then(function(data) {
alert(data.body);
})
.catch(e => alert(e.err));

The response returned is:

<!doctype html><html lang="en"><head><title>HTTP Status 403 – Forbidden</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}</style></head><body><h1>HTTP Status 403 – Forbidden</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Request not in an authorized API scope</p><p><b>Description</b> The server understood the request but refuses to authorize it.</p><hr class="line" /><h3>Apache Tomcat/7.0.91</h3></body></html>

I have looked at many similar issues in the community. I have tried the 'X-Atlassian-Token' :'no-check' header as well, but this doesn't appear to help.

Any suggestions would be appreciated.

 

 

2 answers

0 votes
Mehmet A _Bloompeak_
Atlassian Partner
September 4, 2020

Hi @Mark Sliwinski ,

I guess you are calling AP.request using an app. The app must have WRITE scope to be able to create an issue.  See the scope documentation for the details.

https://developer.atlassian.com/cloud/jira/platform/scopes/

Mark Sliwinski September 4, 2020

Thanks for your response @Mehmet A _Bloompeak_ 

Yes, I am calling this from and an add-on/app. I originally just had "READ", "WRITE" in my list of scopes. I have since updated the list of scopes in my atlassian-connect.json file to:

    },    "scopes"[ "READ", "WRITE",  "DELETE", "ADMIN", "ACT_AS_USER" ],  "modules": { ...

Still no luck.

0 votes
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 1, 2020

In the curl I can see -u user:pwd, but I see no authentication in the AP.Request you provided -- could that be it?

Mark Sliwinski September 1, 2020

@Radek Dostál  Thanks for response, but no. I don't think that is the issue. I'm using this as a standard request throughout my app. All other REST API calls all work except for this one.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events