404 on large file upload for todo task attachment
ThomasWiestBF opened this issue · comments
Hello,
I am using the SDK version 2.4.0 and have encountered a strange behaviour/error. I am trying to upload a large file (~5MB) to a ToDo task. The initial POST request to create an upload session is successful, but the API gives me a 404 error with "Unknown Error" on the PUT request for the first file chunk.
Is there a bug or am i missing anything?
Thank you very much!
Code:
$attachmentInfo = new AttachmentInfo();
$attachmentInfo->setAttachmentType(new AttachmentType('file'));
$attachmentInfo->setName($attachmentName);
$attachmentInfo->setSize($fileSize);
$uploadSessionRequestBody = new CreateUploadSessionPostRequestBody();
$uploadSessionRequestBody->setAttachmentInfo($attachmentInfo);
$uploadSession = $this->client->me()
->todo()->lists()->byTodoTaskListId($taskListId)
->tasks()->byTodoTaskId($graphItemId)->attachments()
->createUploadSession()->post($uploadSessionRequestBody)->wait();
$largeFileUpload = new LargeFileUploadTask($uploadSession, $this->client->getRequestAdapter(), $fileStream);
try {
$uploadSessionResult = $largeFileUpload->upload()->wait();
} catch (NetworkExceptionInterface $ex) {
// resume upload in case of network errors
$retries = 0;
$maxRetries = 3;
while ($retries < $maxRetries) {
try {
$uploadSession = $largeFileUpload->resume()->wait();
if ($uploadSession) {
break;
}
} catch (NetworkExceptionInterface $ex) {
$retries++;
}
}
throw $ex;
}