Im trying to send a request to the apiary API and the header is always invalid. The API expect charset as 'utf-8' which is correctly set in the code. At the inspector of the api website you can see that the request hast set charset as UTF-8... Why is the charset at the request in capital letters? how can i fix it?
var Request = new XMLHttpRequest();
Request.open('POST', 'URL');
Request.setRequestHeader('Content-Type', 'application/json; charset=utf-8'); //utf-8!!!
Request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = {
//JSON stuff
};
Request.send(JSON.stringify(body));