I'm trying to use the Microsoft Graph API's createUploadSession
endpoint with the JavaScript SDK and attempting to test the upload with a small file that's just over 3MB. Whenever send a PUT
request, I receive the following error response:
{
"error": {
"code": "InvalidContentRangeHeader",
"message": "Invalid Content-Range header."
}
}
I'm trying to send over the whole file at once, so here's what the request looks like:
const uploadSession = await client
.api(`/me/messages/${messageId}/attachments/createUploadSession`)
.version('beta')
.post({
AttachmentItem: {
attachmentType: 'file',
name: attachment.name,
size: attachment.size,
},
});
const res = await fetch(uploadSession.uploadUrl, {
method: 'PUT',
headers: {
'Content-Type': 'application/octet-stream',
'Content-Range': `bytes 0-${attachment.size - 1}/${attachment.size}`,
'Content-Length': attachment.size,
},
body: attachment.contentBytes,
});
const json = await res.json();
return json;
Is there anything here that I'm missing? If I understand correctly giving the complete range should pass along the entire file.