I am trying to add a file to an Insight object with JavaScript. The POST request is working perfectly fine in Postman but my function returns a HTTP 500 Error :(
function post() {
var data = new FormData();
data.append("file", "C:\\Users\\mhellensb\\Downloads\\image.png");
data.append("encodedComment", "test");
var xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "http://localhost:8081/rest/insight/latest/attachments/object/7");
xhr.setRequestHeader("X-Atlassian-Token", "no-check");
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
xhr.setRequestHeader("Authorization", "Basic eW91Omxvb2tMaWtlQW5JZGlvdA==");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.