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

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

create a space from a REACT application

Hi folks,

I'm trying to create a confluence space and copy info from an existing one, from a REACT application.

For the moment, I'm trying to create a page. I am using Firefox. I get CORS errors, despite applying an add-on called Allow CORS Access-Control-Allow-Origin.

Here's the code:

....
class
 App extends Component {
handleCreatePageButton=(e)=> {  
const title = "gggggggggggggggg";  
const user = "uuuu";  
const password = "pppppppp"  
const URL= 'https://techweb.axway.com/confluence/rest/api/content/';  
const response =  fetch(URL, 
{
    
method: 
'post',    
headers: 
new Headers({
'Content-Type''application/json'    
}),
    
auth: (user, password),
    
data: 
'{"type":"page","title":"' + title + '","ancestors":[{"id":224260969}], "space":{"key":"MTP"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}',
  }) 
   .then((r=> {console.log('r=', r);  r.json()} )    .then(text  => {console.log('AAAA', text);})    


  render () {    
return (      
<div className="App">      
<
button onClick={this.handleCreatePageButton}>Create page in Confluence</button>      </div>

 Here are the errors:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://techweb.axway.com/confluence/rest/api/content/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://techweb.axway.com/confluence/rest/api/content/. (Reason: CORS request did not succeed

TypeError: NetworkError when attempting to fetch resource.

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,601 views 7 7
Join discussion

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