Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) - Office 365

Referred Link - https://social.msdn.microsoft.com/Forums/office/en-US/a542593a-b3e2-4f00-a7cc-81de6dbc6703/error-while-calling-getlistitem-webservice-server-was-unable-to-process-request-access-is?forum=sharepointdevelopmentlegacy


This Error will occur when you try for accessing in Office 365  http:///_vti_bin/Lists.asmx


  • After Adding Web Reference  
  • In Solution Explorer, click Show All Files.
  • Under Web Reference, expand your web service reference.
  •  Expand Reference.map, and then double click Reference.cs to open the file.
  • Add these class to Reference.cs file

public partial class Lists : System.Web.Services.Protocols.SoapHttpClientProtocol
{
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{

System.Net.WebRequest wr = null;
try
{
wr = base.GetWebRequest(uri);
wr.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
}
catch (Exception ex)
{

}

return wr;
}

}

You May Also Like

0 comments