-
Notifications
You must be signed in to change notification settings - Fork 145
Description
Hi,
using graph v6.1.0 we get:
com.microsoft.kiota.ApiException: generalException
at com.microsoft.kiota.ApiExceptionBuilder.withMessage(ApiExceptionBuilder.java:45)
at com.microsoft.graph.core.requests.upload.UploadResponseHandler.handleResponse(UploadResponseHandler.java:61)
at com.microsoft.graph.core.requests.upload.UploadSliceRequestBuilder.put(UploadSliceRequestBuilder.java:69)
at com.microsoft.graph.core.tasks.LargeFileUploadTask.uploadSlice(LargeFileUploadTask.java:207)
at com.microsoft.graph.core.tasks.LargeFileUploadTask.upload(LargeFileUploadTask.java:131)
for this code:
private fun uploadAttachment(messageId: String, inputStream: InputStream, filename: String): UploadResult<FileAttachment>? {
val largeAttachment = AttachmentItem().apply {
attachmentType = AttachmentType.File
name = filename
size = inputStream.available().toLong()
odataType = "#microsoft.graph.attachmentItem"
}
val uploadSessionPostRequestBody = CreateUploadSessionPostRequestBody().apply {
attachmentItem = largeAttachment
}
val uploadSession = graphClientUser
.messages()
.byMessageId(messageId)
.attachments()
.createUploadSession()
.post(uploadSessionPostRequestBody)
val callback = IProgressCallback { current, max ->
log.info("Uploaded $filename $current bytes of $max total bytes")
}
uploadSession?.let {
val largeFileUploadTask = LargeFileUploadTask(
graphClient.requestAdapter,
it,
inputStream,
largeAttachment.size!!,
FileAttachment::createFromDiscriminatorValue
)
try {
val uploadResult = largeFileUploadTask.upload(1, callback)
log.info("Upload of $filename successful: ${uploadResult?.isUploadSuccessful}")
return uploadResult
} catch (e: Exception) {
log.error(e.message)
throw e
}
}
throw RuntimeException("no session")
}failing line is
val uploadResult = largeFileUploadTask.upload(1, callback)
We tried to adhere to this migration example here:
https://github.com/microsoftgraph/msgraph-sdk-java/blob/59581c120f2b0459512f4b19e7f2725d2699ea9b/docs/upgrade-to-v6.md#large-file-upload-enhancements
Our case uploads to a (mail) message, the previous graph release 5.58.0 was successful, using the same mailbox
debugging, we see no more than this:

the message we upload to, was created before this upload:
graphClient.user(...).mailFolders().byMailFolderId(configurationProperties.mailbox.draftId).messages().post(message)
(authentication is application registration, not delegated)