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

Cors Error with Rest API


I created the code below to create issues in Jira from Confluence using HTML Macros with Ajax, but I have the following error:

to XMLHttpRequest at 'http://localhost:8080/rest/api/2/issue/' from origin 'http://localhost:8090' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:8090, http://localhost:8090', but only one is allowed. Access

There is a CORS blocking the URL, I put the confluence address on Jira's whitelist but I didn't succeed

function criarIssue() { 
//This creates a issue in jira.
var demanda2 = $("#demanda");
var username = "myuser";
var password = "mypass";
var link2 = $("#link");
var jsondata = { "fields":
{ "project": { "key": "B3B" },
"summary": demanda2.val(),
"description": "[Demanda Externa |" + link2.val() +"]",
"reporter": { "name": AJS.params.remoteUser },
"issuetype": { "name": "DP" }
} }; $.ajax({ type: "POST",
url: "http://localhost:8080/rest/api/2/issue/",
contentType: "application/json; charset=utf-8",
headers: { "Authorization": "Basic " + "blablablablabla==" },
dataType: "json", async: false, data: JSON.stringify(jsondata),
success: function(response) {
dataToReturn = (response["key"]);
console.log('issue created!'); },
error: function(xhr, errorText) { console.log('Error ' + xhr.responseText); } });
return dataToReturn; }

 Is there a way to resolve this without browsers plugins ?  

1 answer

1 accepted

2 votes
Answer accepted

Hi @Lucas Rodrigues de Oliveira ,

You could create the following User Macro in Confluence, however, for this to work you must have an Application Link between Jira and Confluence working.

If the Application Link is configured with OAuth only, you must Allow the user in Confluence performing the action to perform Actions with Jira, the famous Login & Approve.

## Macro title: My Create Jira Issue Macro
## Macro has a body: Y
## Body processing: Rendered
## Output: No Output
## Developed by: Rafael Pinto Sperafico
## Date created: 04/09/2019
## Installed by: Rafael Pinto Sperafico

## User Macro to create Jira issue
## @noparams

<script type="text/javascript">
AJS.toInit(function() {
var createIssue = function(applicationLink) {
var payload = '{"issues":{"fields":{"project":{"key":"PROJ"},"issuetype":{"name":"Task"},"summary":"CREATE ISSUE FROM CONFLUENCE","description":"USER MACRO DID THAT"}}}';

url: AJS.Confluence.getBaseUrl() + '/rest/jira-integration/1.0/issues?applicationId=' +,
type: "POST",
contentType: "application/json",
data: payload,
success: function(data) {
.done(function(data) {

// Get a list of all application link configured in Confluence
url: AJS.Confluence.getBaseUrl() + '/rest/applinks/1.0/listApplicationlinks.json',
type: "GET",
dataType: "json",
success: function(data) {
.done(function(data) {
// Iterate over a list of application links
// search for Jira application link
// create issue in Jira application link found
jQuery.each(data.list, function(i, v) {
if (v.application.typeId == 'jira') {

Tested on Confluence 6.6.7 and 6.15.2.

Kind regards,

Hi Rafal,


Thankyou, your solution is the best!!!


I resolved my problem with a reverse proxy but, i'll implement your suggest in future versions of my application. 


Again, Thankyou! it's a elegant solution.

Kind regards,



Suggest an answer

Log in or Sign up to answer

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