Myh

Myh

  • NA
  • 198
  • 1.6k

SharePoint 2016 500 (Internal Server Error) When uploading

Mar 12 2021 10:52 PM
Hello Everyone, i am facing an issue with Sp16 when i upload many documents using rest API. when i upload many documents each one is 20mb i am receiving error 500 Internal server error.
any idea about this error and how to solve it?
i tried this https://www.vioreliftode.com/index.php/how-to-make-sharepoint-2016-not-fail-long-running-uploads-large-files/ but it didn't work for me. any other suggesstions?
my post request is below
  1. public async Task<bool> Save(string requestUri, HttpContent content)    
  2. {    
  3.     var credential = new System.Net.NetworkCredential(    
  4.         username,    
  5.         password,    
  6.         domain);   
  7.     using (var handler = new HttpClientHandler() { Credentials = credential, UseProxy = false })    
  8.     {    
  9.         using (var client = new HttpClient(handler))    
  10.         {    
  11.             client.DefaultRequestHeaders.Accept.Clear();    
  12.             var mediaType = new MediaTypeWithQualityHeaderValue("application/json");    
  13.             mediaType.Parameters.Add(new NameValueHeaderValue("odata""nometadata"));    
  14.             client.DefaultRequestHeaders.Accept.Add(mediaType);    
  15.             client.DefaultRequestHeaders.Add("X-RequestDigest", await this.GetRequestDigest());    
  16.             client.DefaultRequestHeaders.Add("binaryStringRequestBody""true");  
  17.             string postUrl = this.siteUrl.EndsWith("/") ? $"{this.siteUrl}{requestUri}" : $"{this.siteUrl}/{requestUri}";    
  18.             this.logger.LogDebug("Executing SharePointService.Save: PostUrl={0}.", postUrl);  
  19.             HttpResponseMessage response = await client.PostAsync(postUrl, content);    
  20.             response.EnsureSuccessStatusCode();    
  21.             this.logger.LogDebug("Executed SharePointService.Save: PostUrl={0}", postUrl);  
  22.             return true;    
  23.         }    
  24.     }    
  25. }  

Answers (1)