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.