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.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the curl I can see -u user:pwd, but I see no authentication in the AP.Request you provided -- could that be it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.