How to Send a body of data to XMLHttpRequest that looks like this?

Have you tried it out yet? You can't just assume that you are going to encounter errors. You wouldn't know unless you try. Try you first method, if it fails, you would have discovered a way that won't work. Then you find other ways that would work, that's how we learn. It is from the errors and failures that we learn not from the successes.

That being said, if your method fails as you have assumed, try to use JSON.stringify on the params before sending it just like this

xhr.send(JSON.stringify(params))

That should work.


var xhr = new XMLHttpRequest();
   xhr.open(method, url);
   xhr.setRequestHeader('Authorization', 'Bearer ' + access_token);
   xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
   xhr.onload = requestComplete;
   xhr.send(JSON.stringify(params));

It looks like you just needed to stringify your params before passing them to send()