I am using this script here:
var newBodyText = '<div class=\"carousel\"><ac:link ac:anchor=\"Anchor Link\"><ac:link-body><ac:image><ri:url ri:value="http://confluence.atlassian.com/
images/logo/confluence_48_trans.png" /></ac:image></ac:link-body></ac:link></div>';
jQuery.ajax({
url: contextPath + "/rest/api/content/" + AJS.params.pageId + "?expand=body.storage,version,ancestors",
success: function(response) {
response.body.storage.value = newBodyText;
response.version.number += 1;
jQuery.ajax({
contentType: 'application/json',
type: 'PUT',
url: contextPath + "/rest/api/content/" + AJS.params.pageId,
data: JSON.stringify(response),
success: function(response) {
console.log(response);
console.log("Success!");
},
error: function(response) {
console.log(response);
console.log("Error!");
}
});
}
});
But it’s throwing an error every time, and I can’t find out where. The image link is exactly as described in the Confluence Storage Document here. I also tried not escaping the escaping the quotes:
var newBodyText = '<div class="carousel"><ac:link ac:anchor="Anchor Link"><ac:link-body><ac:image><ri:url ri:value="http://confluence.atlassian.com/
images/logo/confluence_48_trans.png" /></ac:image></ac:link-body></ac:link></div>';
jQuery.ajax({
url: contextPath + "/rest/api/content/" + AJS.params.pageId + "?expand=body.storage,version,ancestors",
success: function(response) {
response.body.storage.value = newBodyText;
response.version.number += 1;
jQuery.ajax({
contentType: 'application/json',
type: 'PUT',
url: contextPath + "/rest/api/content/" + AJS.params.pageId,
data: JSON.stringify(response),
success: function(response) {
console.log(response);
console.log("Success!");
},
error: function(response) {
console.log(response);
console.log("Error!");
}
});
}
});
That one errors out, too. This script always works, so I’m not sure what has happened with this iteration specifically. Any help is appreciated! Thanks!