I used the example here: https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples and others i found to try and create a page in confluence using jquery
<html>
<head>
<script src="jquery-1.11.1.min.js"></script>
<script>
var username = "admin";
var password = "admin";
var jsondata = {"type":"page",
"title":"My Test Page",
"space":{"key":"mySpaceKey"},
"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}};
$.ajax
({
type: "POST",
url: "http://localhost:8080/confluence/rest/api/content/",
contentType:"application/json; charset=utf-8",
dataType: "jsonp",
async: true,
headers: {
"Authorization": "Basic " + btoa(username+ ":" + password)
},
data: JSON.stringify(jsondata),
success: function (){
console.log('success');
},
error : function(xhr,status errorText){
console.log(errorText);
}
});
</script>
<body></body>
</head>
</html>
It goes to the success function but doesnt create the page, I tried different dataTypes/url and so on, but I dont understand why it wont work.
Anyonw knows what is the problem?
Thank you!