Sharepoint Rest API(add file) request returning http 500 when using Transfer-Encoding chunked

Ricardo Fernando Goncalves 1 Reputation point
2021-07-15T15:49:14.443+00:00

Hi,

I'm hitting my sharepoint online site, to add files to the 'Shared Documents' list.

Trying from postman, I can get the access token (https://accounts.accesscontrol.windows.net/xxxxxxx-xxxx-xxxxx-xxxxx-xxxxxxxx/tokens/OAuth/2) and also add file to Sharepoint successfully (_api/web/getfolderbyserverrelativeurl('Shared Documents')/Files/add(overwrite=true, url='myfile.json').

But, we have a api gateway here, and when it receive our requests, it add a Transfer-Encoding:chunked Header to the target (Sharepoint in this case). It is a rule from our api gateway.

So, If I try send by postman, for example, a request (either token or add file) with Transfer-Encoding:chunked Header, I'm getting http 500, with body (application/json;odata=nometadata):

{
    "odata.error": {
        "code": "-1, System.IO.IOException",
        "message": {
            "lang": "en-US",
            "value": "I/O error occurred."
        }
    }
}

My Request:

POST mySPsite/_api/web/getfolderbyserverrelativeurl('Shared Documents')/Files/add(overwrite=true, url='myfile.json')
Content-Type: application/json
Authorization: Bearer 'mytokendata'
Accept: application/json;odata=nometadata
Transfer-Encoding: chunked
User-Agent: PostmanRuntime/7.13.0
Cache-Control: no-cache
Postman-Token: cf5b880a-159e-4570-aff6-a357c3ead08d
Host: mySPHost
Connection: keep-alive

My Response:

HTTP/1.1 500
status: 500
Cache-Control: private, max-age=0
Transfer-Encoding: chunked
Content-Type: application/json;odata=nometadata;streaming=true;charset=utf-8
Expires: Wed, 30 Jun 2021 16:04:52 GMT
Last-Modified: Thu, 15 Jul 2021 16:04:52 GMT
Vary: Origin
P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
X-SharePointHealthScore: 0
X-SP-SERVERSTATE: ReadOnly=0
DATASERVICEVERSION: 3.0
SPClientServiceRequestDuration: 30
X-AspNet-Version: 4.0.30319
SPRequestGuid: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
request-id: xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
MS-CV: xxxxxxxxxxxxxo/dBHw.0
Strict-Transport-Security: max-age=31536000
X-FRAME-OPTIONS: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com;
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 16.0.0.21430
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
X-Cache: CONFIG_NOCACHE
X-MSEdge-Ref: Ref A: xxxxxxxxxxxxxxxxxxxxxx Ref B: xxxxxxxxxxx Ref C: 2021-07-15T16:04:52Z
Date: Thu, 15 Jul 2021 16:04:51 GMT

How can I deal with Transfer-Encoding:chunked? Is there a solution for this case?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,803 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,031 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 36,091 Reputation points Microsoft Vendor
    2021-07-16T08:34:11.44+00:00

    Hi @Ricardo Fernando Goncalves ,
    Per my test, I could reproduce your issue on my end when adding the header "Transfer-Encoding" in Postman.

    Based on my current test results and research, Sending chunked requests isn’t currently supported in Postman.
    We can’t set chunked request in postman.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    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.