none
SharePoint Provider Host App Error "The remote server returned an error: (401) Unauthorized. "

    Question

  • When I run the app from Visual Studio, I get the page where I opt to trust the app. However, I get the 401 Unauthorized error when I try to access the app from the site.

    Stack trace:
    [WebException: The remote server returned an error: (401) Unauthorized.]
       System.Net.HttpWebRequest.GetResponse() +1788
       Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute() +49
       Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) +973
       DemoAppWeb.Pages.Default.Page_Load(Object sender, EventArgs e) +401
       System.Web.UI.Control.OnLoad(EventArgs e) +109
       System.Web.UI.Control.LoadRecursive() +68
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4498

    I ran the Set-SPAppPrincipalPermission  cmd also.

    Friday, May 13, 2016 2:31 PM

Answers

  • Hello Gowtham Rajamanickam,

    Change Issuer ID with Lowercase format and creaate a new certificate and try that

    If you still have any questions, please feel free to ask.
    Please Mark This As Answer if it solved your issue or Vote This As Helpful if it helps to solve your issue.         Thank you!

    Friday, May 20, 2016 6:39 AM

All replies

  • Hi Gowtham,

    According to the error message, seems that the error occurs at the page_load event of the default page of the app.

    A guess is that, code in the default page has action which might cause the 401 error.

    For narrowing down the issue, I suggest you create a new app with minimal customization, deploy and open it to see if the issue persists.

    Best regards,

    Patrick

    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Tuesday, May 17, 2016 7:47 AM
    Moderator
  • Hello Gowtham Rajamanickam,

    Change Issuer ID with Lowercase format and creaate a new certificate and try that

    If you still have any questions, please feel free to ask.
    Please Mark This As Answer if it solved your issue or Vote This As Helpful if it helps to solve your issue.         Thank you!

    Friday, May 20, 2016 6:39 AM