Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Connect to Confluence Cloud via REST Api in javascript leads to CORS error

Phil F January 13, 2015

Hi,

I'm trying to connect to our confluence cloud wiki via the REST Api. This is done in javascript with a jQuery ajax request: 

url = 'https://???.atlassian.net/wiki/rest/api/content/1409034?expand=body.view';            
var encode = Base64.encode("EMAIL:PASSWORD");
            
$.ajax({
	type: "GET",
	url: url,
	dataType: 'json',
	crossDomain: true,
	beforeSend: function (xhr) {
		xhr.setRequestHeader("Authorization", "Basic "+encode);
	},
	success: function (){
		console.log("success");
	}
});

 

This request leads to the following CORS error:

XMLHttpRequest cannot load https://smashdocs.atlassian.net/wiki/rest/api/content/1409034?expand=body.view. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

 

I have activated the Remote API and the anonymous access to the Remote API in the confluence administration settings, but that doesn't solve the problem.

 

Any ideas? Or is this impossible with the cloud version confluence?

5 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Dong June 7, 2018

I got this problem as well, is there solution?

0 votes
Rob Jackson March 8, 2017

Hey Phil, were you ever able to resolve this? We're hitting a similar wall with Confluence Cloud and Support wasn't able to assist. 

0 votes
Torsten Priebe July 14, 2016

I have the very same issue. Any news on this?

0 votes
Phil F January 13, 2015

Hi Sash,

yes, I have tried that. This leads to the next error:

Refused to execute script from 'https://???.atlassian.net/wiki/rest/api/content/1409034?expand=body.view&callback=jQuery110202722693895921111_1421155061833&_=1421155061834' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
0 votes
Alex Medved _ConfiForms_
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.
January 13, 2015

Have you tried setting dataType to jsonp?

dataType: 'jsonp',
crossDomain: true,

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events