What should be my application s behavior when I receive error 400 code : InvalidStart during an attachment file upload ?

geoffrey rannou 1 Reputation point
2022-10-03T15:59:26.66+00:00

I had an issue similar to https://learn.microsoft.com/en-us/answers/questions/504422/graph-return-exception-message-34invalid-start-off.html

when I was trying to add some file attachments on an email I had random errors 400 code : InvalidStart

My default behavior when I get an HTTP response NULL is to retry the last request.
The Graph response to the retry attempt is :
HTTP code 400 : {"error":{"code":"InvalidStart","message":"Invalid Start offset for the current fragment. Fragment might already have been uploaded."}}

What should be my application's behavior when I receive this error?

  • How to detect if the upload request was successfull?
  • Is it possible to get this error 400 if the last chunk was only partially uploaded?
  • Can I consider this error as a success in some cases?

I remember for this type of scenarii the OneDrive API has a feature to ask the missing ranges.
https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#resuming-an-in-progress-upload
I could not find the same feature for the email attachment upload. Could you confirm that this feature is not available?

Is there no other way than to cancel and retry the upload with a new session?
like with OneDrive API : https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#cancel-the-upload-session

detail error 400 code : InvalidStart :

The first time I had three error :
 request-id                          : 056c38d3-5037-c823-046e-17c57cc5e3af
 Date                                : Mon, 03 Oct 2022 09:08:34 GMT

 request-id                          : 6b1b9757-81e8-f2a4-836e-af6828e51e46
 Date                                : Mon, 03 Oct 2022 09:09:20 GMT

 request-id                          : c221fe3a-131d-daa3-a83b-77ed7876377c
 Date                                : Mon, 03 Oct 2022 09:12:46 GMT
and two attachments files were missing

The second time I had two error :
 request-id                          : 7920075b-1f02-9d49-72ee-2cb86b3a042e
 Date                                : Mon, 03 Oct 2022 12:31:23 GMT

 request-id                          : 9151bc31-d36b-f491-5941-8988b1f631b7
 Date                                : Mon, 03 Oct 2022 12:32:19 GMT
(one attachment file were missing)

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,841 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,821 Reputation points
    2022-12-26T04:33:16.63+00:00

    Hello @geoffrey rannou

    I'm unable to reproduce this behavior and able to upload my files using this Graph API. Seeing the error message, it seems like you are not passing correct set/range of values in request headers. I would recommend you raise a support case with Microsoft Graph, a Support Engineer will be able to assist you better. You can raise support ticket from http://aad.portal.azure.com/ or https://admin.microsoft.com/#/support/requests.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.