Question

ShinojKumar on Tue, 11 Apr 2017 07:15:28


Team,

We have a provider hosted app deployed on AWS(.net code). On SharePoint Dedicated tenant environment  everything was working as expected.

 

But now the environment has been moved to  O365 Vnext. . Apps are not working in new environment!

Attaching the error herewith.

Kindly Share your thoughts!

Server Error in '/QA' Application.

The remote server returned an error: (401) Unauthorized.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 

 
[WebException: The remote server returned an error: (401) Unauthorized.]
   System.Net.HttpWebRequest.GetResponse() +8674060
   Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute() +58
   Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) +975
   Philips.HRDCAppsWeb.HelperClasses.NewsItemHelper.GetNewsItems(String& duration) +2930
   Philips.HRDCAppsWeb.Pages.NewsCarousel.GetData() +441
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178

 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34280

Regards,

Shinoj


Sponsored



Replies

Vivek Jagga on Wed, 12 Apr 2017 05:20:35


Hi Shinoj,

Error 401 is only for authirization, it seems that you have not updated the ClientID and Client Secret Id in your Azure / AWS app settings.

You have to use the same key at the time of registration of app in your environment. 

there might be a chance that you have missed to update ClientId and ClientSecretID and your app fetch these details from your web.config file of your app.


Vivek Jagga
My Blog
Follow Linkedin Group   


ShinojKumar on Wed, 12 Apr 2017 11:12:23


Hi Lee,

 Thanks for you reply. I have few questions.

1. Sites are geting migrated to O365 Environment. All the existing Librararies, lists , contents are successfullly migrated. What about appcatalog site?

2.I created new client Id and secret from apprenew.aspx and updated in config file. Any changes expected in tokenhelper.cs or SharePointcontext.cs files

3. Will Hightrust or Low trust will matter here? as we are having below snippet

 static SharePointContextProvider()
        {
            if (!TokenHelper.IsHighTrustApp())
            {
                SharePointContextProvider.current = new SharePointAcsContextProvider();
            }
            else
            {
                SharePointContextProvider.current = new SharePointHighTrustContextProvider();
            }
        }

Thanks

Shinoj

ShinojKumar on Wed, 12 Apr 2017 11:19:14


Hi Vivek,

Thanks for responding!

Yes I did. Updated client Id and Secret. We are hosting app's .net code on  Amazon server. I am little confused about uploading .app file in new environment's app catalog site. I mentioned this thing in reply to Lee's response.

Anything special to be taken care for O365 Site-amazon server connection or does it work exactly like in Azure?

Thanks,

Shinoj

Lee__li on Wed, 19 Apr 2017 03:51:19


Hi,

I would suggest you check does your app exists in app catalog site manually.

Go to Admin center->Admin->SharePoint->apps->App Catalog->Apps for SharePoint

You could check below thread for reference.

http://www.c-sharpcorner.com/UploadFile/anavijai/office-365-how-to-set-up-an-app-catalog-on-sharepoint-2013/

 

We can use  Low trust app in SharePoint online only, when you update the client Id and secret for your app, make sure you update these values in app Web.config.

Here is the guideline for your reference.

https://msdn.microsoft.com/en-us/library/office/dn726681.aspx?f=255&MSPPError=-2147217396

 

Make sure the app new ClientId exists in /_layouts/15/AppPrincipals.aspx.(after you updating your app instance in specific site)

Best Regards,

Lee


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

Lee__li on Tue, 25 Apr 2017 05:15:26


Hi,

I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

You can mark the helpful post as answer to help other community members find the helpful information quickly.

You can also share your own solution here and mark it as answer, and we can learn from each other.

Best Regards,

Lee