question

NealAnthony-1420 avatar image
0 Votes"
NealAnthony-1420 asked NealAnthony-1420 answered

HttpClient Post zip file to Sharepoint Rest API results in corrupt zip file

Good afternoon. I have an Azure function that is triggered when a blob drops into a blob container in an azure storage account. The function uses an HttpClient library asynchronous post to sharepoint via the sharepoint REST API. When I download the resulting zip file from Sharepoint, I am unable to open the file with Windows extractor (it will open with WinRar, but that is not the end goal). I then use a utility to open the same file in my Azure storage and compare with the file that I sent to Sharepoint. The Sharepoint file has additional header data in it. If I manually remove the header data from the corrupted file, I can open the file with Windows Extractor. A little further information, the additional header in the corrupt file is the content-disposition header.

dotnet-csharpazure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MughundhanRaveendran-MSFT avatar image
0 Votes"
MughundhanRaveendran-MSFT answered MughundhanRaveendran-MSFT commented

@NealAnthony-1420 ,

Thanks for reaching out to Q&A forum.

You can remove the header using the below code programmatically

HttpContext.Current.Response.Headers.Remove("Header-name");

Similar discussion here: https://stackoverflow.com/questions/3418557/how-to-remove-asp-net-mvc-default-http-headers

Please note that, this issue is not related to Azure functions. You should be able reproduce this issue outside the Azure environment as well.

I hope this helps!

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@NealAnthony-1420 ,
Following up to see if the above answer helps. Do let us know if you have any queries.

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

0 Votes 0 ·
NealAnthony-1420 avatar image
0 Votes"
NealAnthony-1420 answered

Thank You for following up. I switched to HttpClientFactory and everything started working. Thank You for your help.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.