I have created a randomized quiz in a Confluence HTML Macro using javascript. The quiz is a knowledge check for users who wish to gain access to an application they have taken training for.
At the conclusion of the training, I want to either add a comment to an existing JIRA, or create a new JIRA, using the rest api or use automation with a webhook to generate a JIRA.
I am able to use get in the rest api for myself or a specific JIRA and display the returned values, so that is working fine. However, when I try the 'POST' method to add a comment, add an issue, or use a webhook, I get 403 forbidden. I was getting a CORS error orignally, but I resolved that through a proxy. Now I get the 403 forbidden error.
The get doesn't even require authorization in the header for some reason.
I've tried using 'Basic ' + btoa(userName + ':' + accessToken) in the header, but to no avail. I've also tried 'Bearer ' + accessToken, and have tried my password instead of the personal access token. All results in 403 forbidden.
Anyone have ideas how to resolve?
function updateJiraIssue() { const apiUrl = 'https://confluence.net/plugins/servlet/applinks/proxy?appId=0f4bdff9-e31c-37bc-ae42-&path=/rest/api/latest/issue/XFCH-6365/comment'; const accessToken = 'xxxx'; const userName = 'username'; const data = { body: 'test comment' }; fetch(apiUrl, { method: 'POST', headers: { 'Authorization': 'Basic ' + btoa(userName + ':' + accessToken), 'Content-type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(data) }) }
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.