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.