Skip to main content
Box Employee
May 22, 2025 6:01 AM UTC
Question

Request_size_mismatch error with FilesManager.CreateNewVersionUploadSessionAsync()

I'm trying to implement chunked uploads for new file versions, and unfortunately I'm stumped at the very first step!

 

When calling the following code to start the session, I get the below error:

 

var boxFileUploadSession = await this.Client.FilesManager.CreateNewVersionUploadSessionAsync(fileId, fileSize.ToString());

 

 

{"code":"request_size_mismatch","message":"Request body size didn't match Content-Length 19","request_id":"f9b14c82069f3bcc885970545782058b"}

 

In Fiddler I can see the request looks fine:

POST https://upload.box.com/api/2.1/files/***number removed for privacy***422/upload_sessions HTTP/1.1
User-Agent: Box Windows SDK v2.15.6
Authorization: Bearer [removed]
Content-Type: application/x-www-form-urlencoded
Host: upload.box.com
Cookie: box_visitor_id=[removed]; site_preference=desktop
Content-Length: 19
Accept-Encoding: gzip, deflate

file_size=***number removed for privacy***

 

As you can see the body content is actually 19 bytes.

 

Am I doing something wrong? I don't have any similar issues creating a normal session with CreateUploadSessionAsync().

 

 

Thanks,

Martin

 

    2 replies

    Box Employee
    May 22, 2025 6:01 AM UTC

    Did you ever figure this out?

     

    I'm getting the same error in PHP, but not in Postman.

    Translate
    Box Employee
    May 22, 2025 6:01 AM UTC

    We resolved the issue.  The Content-Type needs to be application/json in the request header ("Content-Type: application/json").

    Translate