0
votes

I'm using JavaScript to make a POST request to create a message to Office 365 with xhr (Or using Faraday gem to make POST request - Ruby on Rails).My flow is encode file to base64 and create a JSON contain all attachments(encoded) then POST to https://outlook.office.com/api/v1.0/me/sendmail.

var endpointUrl = "https://outlook.office.com/api/v1.0/me/sendmail";
    var xhr = new XMLHttpRequest();
    xhr.open("POST", endpointUrl);
    xhr.setRequestHeader("Authorization", "Bearer " + token);
    xhr.setRequestHeader("content-type", "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8");
    xhr.send(JSON.stringify(result));
}

This code can send message with about 22,5MB attachments, but if all attachments have more than 23MB, I got 404 error reponse and the cosole write:

XMLHttpRequest cannot load https://outlook.office.com/api/v1.0/me/sendmail. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404.


Alr set message size restrictions to max 153600 Could someone help me? Thank you !

1
What is the size of the payload (message + attachments) after encoding for the failure and success cases?Venkat Ayyadevara - MSFT
@VenkatAyyadevara-MSFT Sorry, now I got my payload's size. After encode 20mb files with empty mail body, i got about 27mb size of payload and Fail. It's successfully with 15mb files (after encode, size of payload is 19mb).Hom nom nom nom ...
Thanks for the info. Can you please try your request to outlook.office365.com instead of outlook.office.com and see if the 27mb payload and 19mb payload messages succeed?Venkat Ayyadevara - MSFT
@VenkatAyyadevara-MSFT Hi, while I'm using outlook.office365.com, I got new error when try to send 30mb attachments.<br> The maximum number of bytes allowed to be read from the stream has been exceeded. After the last read operation, a total of 38798336 bytes has been read from the stream; however a maximum of 38797312 bytes is allowed.Hom nom nom nom ...
Thanks for the info. Will check with my team and get back to you.Venkat Ayyadevara - MSFT

1 Answers

1
votes

It does look like you are running into a limit on the max size of the payload. The limit currently is 37 MB and a lower limit is being enforced through outlook.office.com. We have opened a work item to increase this limit to allow the max attachment size we can store in Office 365 (150 MB), but you will need to wait for that to be completed before you can send messages of the sizes you are attempting to send.