In my experience the best way to approach this is to manually add the KML as a portal item using the Add Item option from My Contents and use your browser's dev tools to look at the request that gets sent (chrome has a preserve log option to make sure the network log keeps the request). You can use this request as a template for what your request has to do.
That aside, here's some code I've used to upload to upload files as portal items using esri/request:
function addFileaAsPortalItem(user, fileList, tags){
const file = fileList[0];
let form = new FormData();
form.append('file',file);
form.append("f", "json");
form.append("title", file.name);
form.append("name", file.name);
form.append("type",'KML');
form.append("token", <server token>);
form.append("filename", file.name);
form.append("tags", tags.join());
return esriRequest(`${user.userContentUrl}/addItem`,{
method: 'post',
query: form
});
}
I'm not sure if this will fail when the file is too large. I've used it to upload images, kml, text documents, and more. It also may be a good idea to use esri/request for this, as opposed to the fetch api.