Arithmetic operation resulted in an overflow - The remote server returned an error: (407) Proxy Authentication Required

Hello I read and tried the previous forum suggestions. I have deleted the role and readded it. I use a domain account that is able to get through the proxy. Each time a variant of the Proxy error is returned. The site is on server 2008 R2.
The AI certificate is valid and specified in the console. I am not sure what could be missing. Everything used to work as specified on Server 2003. This configuration is the same, but it is no longer able to sync. Thanks.   

Would recommend that you elaborate on what issue you are facing so that the community can help.
Blog: http://theinfraguys.com
Follow me at Facebook
The Infra Guys Facebook Page
Join the Singapore System Center Admin Group
SG System Center Admin Group
Please remember to click Mark as Answer on the answer if it helps you in anyway

Similar Messages

  • Powershell Error for SharePoint Online -"The remote server returned an error: (407) Proxy Authentication Required."

    I am trying to call sharepoint online from powershell. Below is the code. I get 
    Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (407) Proxy Authentication Required."
    $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
    $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
    $webUrl = "ZZZZ"
    $username = "XXX"
    $password = "YYYY"
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl) 
    $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
    $web = $ctx.Web
    $lists = $web.Lists 
    $ctx.Load($lists)
    $ctx.ExecuteQuery()
    $lists| select -Property Title
    Raj-Shpt

    Hi,
    About how to access SharePoint online site using PowerShell, the blog below would be helpful:
    http://social.technet.microsoft.com/wiki/contents/articles/29518.csom-sharepoint-powershell-reference-and-example-codes.aspx
    Another two demos for your reference:
    http://www.hartsteve.com/2013/06/sharepoint-online-powershell/
    http://www.sharepointnutsandbolts.com/2013/12/Using-CSOM-in-PowerShell-scripts-with-Office365.html
    Thanks
    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
    [email protected]

  • The remote server returned an error

    hi Expert,
    New error I find now when trying to use dashboard application in B1. It sounds nice to have this new one since there is no info or solution in the SAP files or notes. The error message is the remote server returned an error : (407) proxy authentication required.
    What could be the cause of the error ? is it bugs ? Pls adv. Thx
    John

    Hello
    Is the DI Proxy Service is runnig? Can you test the connection from Landscape?
    Regards
    János

  • Error: Load operation failed for query 'GetAuthenticationInfo'. The remote server returned an error: NotFound.

    Hello,
    I have a lightswitch web-application in development, which I need to copy from one computer to the other. I have tried doing it both through Git and by simply copying the solution and opening the project on another machine. The project builds without errors,
    but when I try to debug it, it opens a web-browser, loads to 100% and pops up an error - Load operation failed for query 'GetAuthenticationInfo'. The remote server returned an error: NotFound.
    Now, I have tried repairing Visual Studio on my machine, reinstalling .NET framework and setting  <basicAuthentication enabled="false" /> in web.config, yet it still does not run.
    When using Fiddler, it shows an error while loading the application - "HTTP/1.1 500 Internal Server Error" , which I honestly don't know what it means.
    The application uses ComponentOne and Telerik modules, but they are both installed on both machines. 
    The application does run perfectly on the original machine, but it is not working on any other one.
    Both machines are using Win 8.1 and Visual Studio 2013 Update 4.
    I have tried to look this up online, but most people's problem are when they are deploying the app, not just debugging. I would be really happy for any help with this issue.
    Thanks!

    I have the same problem on one of my development machines. Whenever I create a new project, the System.IdentityModel.Tokens.Jwt nuget package is not referenced properly. The project compiles correctly but you are not able to debug as I get the same error
    as you.
    If you open up your references and there is an error next to any of your references make sure that you correct them. In the case of the jwt reference error, I have to remove the jwt reference and then add it back from the packages folder.
    This may not be your problem but could point you in a direction?

  • Workflow Manager for SP2013. The remote server returned an error: (500) Internal Server Error.

    I am *almost* all the way through provisioning my on premise SP 2013 farm for SharePoint 2013 Workflows.  Workflow manager is installed alongside Service Bus.  Workflow Manager client is installed on the SP servers.  I built a new simple list-based
    workflow in SP Designer 2013, saved it, and published it without any errors.  However, when I go back to the list in my portal and try to run the workflow, I get the "Sorry, something went wrong" page, and the logs say this:
    05/15/2013 12:41:05.07  w3wp.exe (0x071C)                        0x085C SharePoint Foundation        
     Runtime                        tkau Unexpected System.Net.WebException: The remote server returned an error: (500) Internal Server
    Error.    at Microsoft.Workflow.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)     at Microsoft.Workflow.Client.HttpGetResponseAsyncResult`1.End(IAsyncResult result)     at Microsoft.Workflow.Client.ClientHelpers.SendRequest[T](HttpWebRequest
    request, T content) 27be1b9c-f990-f096-34a8-7ac8816bc7a5
    05/15/2013 12:41:05.08  w3wp.exe (0x071C)                        0x085C SharePoint Foundation        
     General                        ajlz0 High     Getting Error Message for Exception System.Web.HttpUnhandledException
    (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> Microsoft.Workflow.Client.InternalServerException: Exception thrown from the data layer. For more details, please see the server logs. HTTP headers received from the server
    - ActivityId: 0c03f692-8153-43a7-bed5-096214b06168. NodeId: VM22. Scope: /SharePoint/default/d386fdc7-ea7b-4d46-9a39-5c114096eef8/f203a564-e83a-47a3-b11b-e432ac1e6dab. Client ActivityId : 27be1b9c-f990-f096-34a8-7ac8816bc7a5. ---> System.Net.WebException:
    The remote server returned an error: (500) Internal Server Error.     at Microsoft.Workflow.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)     at Microsoft.Workflow.Client.HttpGetResponseAsyncResult`1.End(... 27be1b9c-f990-f096-34a8-7ac8816bc7a5
    05/15/2013 12:41:05.08* w3wp.exe (0x071C)                        0x085C SharePoint Foundation        
     General                        ajlz0 High     ...IAsyncResult result)     at Microsoft.Workflow.Client.ClientHelpers.SendRequest[T](HttpWebRequest
    request, T content)     --- End of inner exception stack trace ---     at Microsoft.Workflow.Client.ClientHelpers.SendRequest[T](HttpWebRequest request, T content)     at Microsoft.Workflow.Client.InstanceManager.GetInternal(Int32
    skip, Int32 count, String workflowName, WorkflowInstanceStatus workflowStatus, IDictionary`2 activationMetadataFilter)     at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateByMonitoringParameter(Guid monitoringParameter,
    Int32 offset, Int32 count, Boolean checkPermissions)     at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateInstancesForListItem(Guid listId, Int32 itemId, Int32 offset)     at Microsoft.Sh... 27be1b9c-f990-f096-34a8-7ac8816bc7a5
    05/15/2013 12:41:05.08* w3wp.exe (0x071C)                        0x085C SharePoint Foundation        
     General                        ajlz0 High     ...arePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateInstancesForListItem(Guid
    listId, Int32 itemId)     at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPageBase.ConstructStatusArraysWF4(ArrayList running, ArrayList completed, Boolean onlyMyWorkflows)     at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPage.ConstructStatusArrays()    
    at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPage.OnLoad(EventArgs e)     at System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
    Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.HandleError(Exception e)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStages... 27be1b9c-f990-f096-34a8-7ac8816bc7a5
    05/15/2013 12:41:05.08* w3wp.exe (0x071C)                        0x085C SharePoint Foundation        
     General                        ajlz0 High     ...AfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest()     at System.Web.UI.Page.ProcessRequest(HttpContext context)     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()    
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 27be1b9c-f990-f096-34a8-7ac8816bc7a5
    05/15/2013 12:41:05.08  w3wp.exe (0x071C)                        0x085C SharePoint Foundation        
     General                        aat87 Monitorable   27be1b9c-f990-f096-34a8-7ac8816bc7a5
    Some sort of "general server error" returns a 500 code, but I can't tell from this what the problem(s) might be. Has anyone seen this before?
    Thanks.

    Go to the server running Workflow Manager and open the Event Viewer; Applications and Services Logs; Microsoft-Workflow; Operational; and look for the underlying error.  In our case, the CU for Workflow Manager did something to the SQL permissions and
    we ended up using the workaraound described here:
    http://social.msdn.microsoft.com/Forums/windowsazure/en-US/054d2a58-8847-4a6a-b1ab-05a79f49fe65/workflow-manager-cumulative-update-february-error?forum=wflmgr
    Joe

  • Return The remote server returned an error: (403) Forbidden error for some file types

    hi
    am using below code to get the byte array 
    byte[] myDataBuffer = client.DownloadData((new Uri(sourceUrl)));
    for source of type .txt/.jpg no problem with accessing.but the file type with .master/.wsp/.cs
    it is returning "The remote server returned an error: (403) Forbidden error for some file types" Error.how can i get rid of this.please help me
    Thanks in Advance

    Hi,
    It seems there is something wrong with your code, from your code the account and key are the same, because their appsetting name are the same.
    string account = ConfigurationManager.AppSettings["StorageAccountName"];
    //string account = CloudConfigurationManager.GetSetting("StorageAccountName");
    //string key = CloudConfigurationManager.GetSetting("StorageAccountAccessKey");
    string key = ConfigurationManager.AppSettings["StorageAccountName"];
    string connectionString = String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", account, key);
    return CloudStorageAccount.Parse(connectionString);
    If you use CloudConfigurationManager.GetSetting, please consider set azure project as the startup project, if not, this value will be null, this resulted in solution being started as a web project that didn't run inside the Azure emulator. Since CloudConfigurationManager.GetSetting
    tries to get setting by contacting Azure (or Azure emulator in this case), and it is not running, it returns null.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Test-ActiveSyncConnectivity fails with The remote server returned an error: (400) Bad Request.

    Hi all,
    I'm on the process of transition from Exchange 2003 to 2010, everything is going perfectly alright however ActiveSync is bugging me!
    when I try to test activesync I get the following error:
    [PS] C:\>Test-ActiveSyncConnectivity -MailboxCredential $user -TrustAnySSLCertificate |FL
    RunspaceId                  : 136b8f68-26ec-4e29-a5bb-cf5ee816e04b
    LocalSite                   : SITE
    SecureAccess                : True
    VirtualDirectoryName        :
    Url                         :
    UrlType                     : Unknown
    Port                        : 0
    ConnectionType              : Plaintext
    ClientAccessServerShortName : cas01
    LocalSiteShortName          : SITE
    ClientAccessServer          : CASSERVERNAME
    Scenario                    : Options
    ScenarioDescription         : Issue an HTTP OPTIONS command to retrieve the Exchange ActiveSync protocol version.
    PerformanceCounterName      :
    Result                      : Success
    Error                       :
    UserName                    : user1
    StartTime                   : 12/12/2012 1:02:23 PM
    Latency                     : 00:00:00.0312496
    EventType                   : Success
    LatencyInMillisecondsString : 31.25
    Identity                    :
    IsValid                     : True
    RunspaceId                  : 136b8f68-26ec-4e29-a5bb-cf5ee816e04b
    LocalSite                   : Reckon_NS
    SecureAccess                : True
    VirtualDirectoryName        :
    Url                         :
    UrlType                     : Unknown
    Port                        : 0
    ConnectionType              : Plaintext
    ClientAccessServerShortName : CASSERVERNAME
    LocalSiteShortName          : SITE
    ClientAccessServer          : CASSERVERNAME
    Scenario                    : FolderSync
    ScenarioDescription         : Issue a FolderSync command to retrieve the folder hierarchy.
    PerformanceCounterName      : DirectPush Latency
    Result                      : Failure
    Error                       : [System.Net.WebException]: The remote server returned an error: (400) Bad Request.
                                  HTTP response headers:
                                  MS-Server-ActiveSync: 6.5.7638.1
                                  Content-Length: 46
                                  Cache-Control: private
                                  Content-Type: text/html
                                  Date: Wed, 12 Dec 2012 02:02:23 GMT
                                  Server: Microsoft-IIS/7.5
                                  X-AspNet-Version: 2.0.50727
                                  X-Powered-By: ASP.NET
    UserName                    : user1
    StartTime                   : 12/12/2012 1:02:23 PM
    Latency                     : -00:00:01
    EventType                   : Error
    LatencyInMillisecondsString :
    Identity                    :
    IsValid                     : True
    environment: 
    Ex 2003 'Exchange' virtual directory permission: Integrated Windows Authentication, Basic 
    Ex 2003 'OMA' permission: Basic Authentication
    Ex 2003 'ActiveSync' permission: Integrated, Basic
    Ex 2010 successfully redirects users from 2010 to 2003 webmail if you login to OWA with a mailbox on 2003

    Yes Martina,
    It has been done through ESM 
    I cannot test using testexchangeconnectivity.com since I cannot put the 2010 one into production, I will get into trouble if I change the DNS record to the new mail server!
    Yes, EAS works perfectly fine with 2010 mailboxes.
    OK.
    It might be that it's not possible to run Test-ActiveSyncConnectivity against a mailbox stored in Exchange 2003.
    Installing KB937031 and enabling Windows Authentication is really all that needs to be done in EX03, in order for Exchange 2010 to proxy the EAS requests.
    Martina Miskovic

  • The remote server returned an error: (401) Unauthorized. while running client context using sharepoint client object model

    Hi,
    I have started using the client object model so that i do not have to go to sharepoint admins to perform some basic operations on remote server. While assigning list item level permission i am getting following error, could you please help. thanks.
    The remote server returned an error: (401) Unauthorized.
       at
    System.Net.HttpWebRequest.GetResponse()
       at
    Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
       at
    Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
       at
    Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
       at
    SetDowntimeItemPermission.SetPermission.Main(String[] args) in

    it seems your request was unauthenticated i'm not sure are you using a web application with FBA or desktop application my suggestion would be try to impersonate your request by passing network credentials (COM works on network credentials )
    NetworkCredential credentials = new NetworkCredential("username", "pwd", "domain");
    ClientContext context = new ClientContext("http://site-url");
    context.Credentials = credentials;
    Best Regards, Ashutosh | SharePoint World

  • The remote server returned an error: (403) Forbidden on container.CreateIfNotExistsAsync() method

    static class StorageUtils
            public static CloudStorageAccount StorageAccount
                get
                    string account = ConfigurationManager.AppSettings["StorageAccountName"];
                    //string account = CloudConfigurationManager.GetSetting("StorageAccountName");
                    //string key = CloudConfigurationManager.GetSetting("StorageAccountAccessKey");
                    string key = ConfigurationManager.AppSettings["StorageAccountName"];
                    string connectionString = String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", account, key);
                    return CloudStorageAccount.Parse(connectionString);
    I have a web project and I converted it to "MS Azure Cloud Service Project"
    I make the Azure project default and run CreateAndConfigureAsync() to create the container. It works fine and creates the images container in Azure storage.
    Then I make my web project default and change CloudConfigurationManager.GetSetting to ConfigurationManager.AppSettings in StorageUtils class and run the web app project. Then I get "The remote server returned an error: (403) Forbidden" error whencontainer.CreateIfNotExistsAsync()
    line get executed.
    What is the reason for this?
    async public void CreateAndConfigureAsync()
                try
                    CloudStorageAccount storageAccount = StorageUtils.StorageAccount;
                    // Create a blob client and retrieve reference to images container
                    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
                    CloudBlobContainer container = blobClient.GetContainerReference("images");
                    // Create the "images" container if it doesn't already exist.
                    if (await container.CreateIfNotExistsAsync())
                        // Enable public access on the newly created "images" container
                        await container.SetPermissionsAsync(
                            new BlobContainerPermissions
                                PublicAccess =
                                    BlobContainerPublicAccessType.Blob
                catch (Exception ex)
            }

    Hi,
    It seems there is something wrong with your code, from your code the account and key are the same, because their appsetting name are the same.
    string account = ConfigurationManager.AppSettings["StorageAccountName"];
    //string account = CloudConfigurationManager.GetSetting("StorageAccountName");
    //string key = CloudConfigurationManager.GetSetting("StorageAccountAccessKey");
    string key = ConfigurationManager.AppSettings["StorageAccountName"];
    string connectionString = String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", account, key);
    return CloudStorageAccount.Parse(connectionString);
    If you use CloudConfigurationManager.GetSetting, please consider set azure project as the startup project, if not, this value will be null, this resulted in solution being started as a web project that didn't run inside the Azure emulator. Since CloudConfigurationManager.GetSetting
    tries to get setting by contacting Azure (or Azure emulator in this case), and it is not running, it returns null.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • WCF Error: The remote server returned an error: Not Found

    I have a windows phone8 app that utilizes a azure WCF service. I added the Servicereference to my project,when i call the service method it executes fine but getting the following error after executing:
    System.ServiceModel.CommunicationException: The remote server returned an error: Not Found
    Here's the code where my error's occuring (the error occurs on the 2nd line of code within the method(the line that contains "_result =
    public string EndSendMessage(System.IAsyncResult result) {
                    object[] _args = new object[0];
                    string _result = ((string)(base.EndInvoke("SendMessage", _args, result)));
                    return _result;
    Any idea why this is happening?
    Thanks.

    Hi Narendramacha,
    It may be have more than one possibility reasons. Did you try the service URL in the phone/emulator Internet Explorer to be sure the url is accessible ? About this error, I found some solutions , please refer to :
    1.maxStringContentLength: http://stackoverflow.com/a/5185678
    2.FireWall: http://stackoverflow.com/a/15594388
    Please try it. Any results, please let me know.
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Error while executing script for sharepoint online (office 365) - the remote server returned an error: (503) server unavailable

    error while executing script for sharepoint online (office 365) - the remote server returned an error: (503) server unavailable.
    I am creating many site collections reading records from sharepoint list using powershell in sharepoint online tenant (office 365).
    Few site collections are created and then getting above error so this error record will be skipped then few succeeding record processed then again getting error.
    pattern is like:
    success
    success
    success
    success
    Error
    success
    success
    success
    success
    success
    success
    error
    success

    Hi,
    As it is an online environment, to troubleshoot this issue in an easier way, I suggest you contact Office 365 Support to see if there is any useful information in
    the log files in the server side:
    https://support.office.com/en-us/article/Contact-Office-365-for-business-support-32a17ca7-6fa0-4870-8a8d-e25ba4ccfd4b?ui=en-US&rs=en-US&ad=US
    Best regards
    Patrick Liang
    TechNet Community Support

  • Power BI analysis services connector - the remote server returned an error (403)

    Hi all, does any one have any suggestions what to try to identify the configuration problem I have?
    I have, a SSAS 2012 tabular instance with SP2, there is a database on the instance with a read role with everyone assigned permissions. 
    When configuring the Power BI analysis services connector, at the point where you enter Friendly Name, Description and Friendly error message, when you click next I receive the error "The remote server returned an error (403)." 
    I've tested connecting to the database from Excel on a desktop and connect fine.
    I don't use a "onmicrosoft" account so don't have that problem to deal with.
    We use Power BI Pro with our Office 365. As far as I can tell that part is working ok as I pass that stage of the configuration with a message saying connected to Power BI.
    The connector is installed on the same server as tabular services, its a Win2012 Standard server. The tabular instance is running a domain account that is the admin account for the instance (this is a dev environment) that account is what I've used in the
    connector configuration. It's also a local admin account. There is no gateway installed on the server.
    Any help would be greatly appreciated, thanks, Brian
    Brian Searle

    Brian-
    One other common issue I've seen is the UPN not quite matching. Log onto the SSAS server as the user who's logged into Power BI. Then open a command prompt and run:
    whoami /upn
    Hopefully the UPN it says will match your EffectiveUserName test and will match exactly how you're signing into the Power BI site.
    If that doesn't work, your best bet is to go to
    http://support.powerbi.com/ and click Contact Support and describe this situation and someone from the Power BI support team should get in touch with you to troubleshoot.
    http://artisconsulting.com/Blogs/GregGalloway

  • Provider-hosted Apps debug error: The remote server returned an error: (401) unauthorised

    Hi,
    Any help appreciated!!
    I'm getting this error: "The remote server returned an error: (401) unauthorised when I debug a provider-hosted app.  I get the error on this line:  
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    See code below
    I created a high trust development environment following the instructions provided here:
    http://msdn.microsoft.com/en-us/library/office/fp179901(v=office.15).aspx and
    http://msdn.microsoft.com/library/office/fp179923
    I created a provider-hosted app with the intent to:
    create a SharePoint list in the appweb
    Use self-signed certificate, tokenhepler.cs and sharepointcontext.cs to retrieve current user context and access on SharePoint.  (No changes were made to tokenhelper.cs and sharepointcontext.cs)
    retrieve list items from the SharePoint list in a button click event handler on a default.aspx of the remote web
    What happens:
    The app is deployed successfully to the Dev site
    The SharePoint feature is deployed and activated
    The default.aspx page of the remote web loads
    The error (see image) is returned on clicking of the button
    My environment is an on-premise SharePoint 2013 with AD and my dev box is standalone windows 8.1 running Visual Studio Professional 2013 Update 3.
    The code block below is a copy of the default.aspx code-behind
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Microsoft.SharePoint.Client;
    using Microsoft.IdentityModel.S2S.Tokens;
    using System.Net;
    using System.IO;
    using System.Xml;
    using System.Data;
    using System.Xml.Linq;
    using System.Xml.XPath;
    namespace Idea.GeneratorWeb
    public partial class Default : System.Web.UI.Page
    SharePointContextToken contextToken;
    string accessToken;
    Uri sharepointUrl;
    protected void Page_PreInit(object sender, EventArgs e)
    Uri redirectUrl;
    switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
    case RedirectionStatus.Ok:
    return;
    case RedirectionStatus.ShouldRedirect:
    Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
    break;
    case RedirectionStatus.CanNotRedirect:
    Response.Write("An error occurred while processing your request.");
    Response.End();
    break;
    protected void Page_Load(object sender, EventArgs e)
    //// The following code gets the client context and Title property by using TokenHelper.
    //// To access other properties, the app may need to request permissions on the host web.
    var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
    //var spContext = new ClientContext("MySPDevInstance");
    //spContext.Credentials = new NetworkCredential("username", "password");
    //using (var clientContext = spContext.CreateUserClientContextForSPHost())
    // clientContext.Load(clientContext.Web, web => web.Title);
    // clientContext.ExecuteQuery();
    // Response.Write(clientContext.Web.Title);
    string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);
    if (contextTokenString != null)
    // Get context token
    contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);
    // Get access token
    sharepointUrl = new Uri(Request.QueryString["SPAppWebUrl"]);
    accessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
    // Pass the access token to the button event handler.
    Button1.CommandArgument = accessToken;
    protected void Button1_Click(object sender, EventArgs e)
    // Retrieve the access token that the Page_Load method stored
    // in the button's command argument.
    string accessToken = ((Button)sender).CommandArgument;
    if (IsPostBack)
    sharepointUrl = new Uri(Request.QueryString["SPAppWebUrl"]);
    // REST/OData URL section
    string oDataUrl = "/_api/Web/lists/getbytitle('Diagrams In Idea Generator')/items?$select=Title,Diagram,SharingStatus";
    // HTTP Request and Response construction section
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(sharepointUrl.ToString() + oDataUrl);
    request.Method = "GET";
    request.Accept = "application/atom+xml";
    request.ContentType = "application/atom+xml;type=entry";
    request.Headers.Add("Authorization", "Bearer " + accessToken);
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    // Response markup parsing section
    XDocument oDataXML = XDocument.Load(response.GetResponseStream(), LoadOptions.None);
    XNamespace atom = "http://www.w3.org/2005/Atom";
    XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
    XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
    List<XElement> entries = oDataXML.Descendants(atom + "entry")
    .Elements(atom + "content")
    .Elements(m + "properties")
    .ToList();
    var entryFieldValues = from entry in entries
    select new
    Character = entry.Element(d + "Title").Value,
    Actor = entry.Element(d + "Diagram").Value,
    CastingStatus = entry.Element(d + "SharingStatus").Value
    GridView1.DataSource = entryFieldValues;
    GridView1.DataBind();
    Any ideas what I might be doing wrong

    Hi ,
    Use the below code
    Public string GetAccessToken(){
    string sharePointSiteUrlHost =  Page.Request["SPHostUrl"].Tostring();
    string AccessToken = tokenHelper.GetS2SAccessTokenWithWindowsIdentity(sharePointSiteUrlHost, Request.LogonUserIdentity);
    return accessToken;
    Than initialize the ClientCOntext with the below Method
     private static ClientContext GetClientContextWithAccessTokenString(string targetUrl, object accessToken)
                ClientContext clientContext = new ClientContext(targetUrl);
                clientContext.AuthenticationMode = ClientAuthenticationMode.Anonymous;
                clientContext.FormDigestHandlingEnabled = false;
                clientContext.ExecutingWebRequest +=
                    delegate(object oSender, WebRequestEventArgs webRequestEventArgs)
                        webRequestEventArgs.WebRequestExecutor.WebRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
                        webRequestEventArgs.WebRequestExecutor.RequestHeaders["Authorization"] =
                            "Bearer " + accessToken;
                return clientContext;
    use this clientCOntext and it will work.
    Do not use
    SharePointContextProvider
    Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

  • Getting "The remote server returned an error 503 server unavailable" in azure web jobs

    I have created one web
    job - on demand schedule under azure web site.  This web jobs contains .execmd(i.e.)
    Console Application.
    I am retrieving the data from SQL Azure database and uploaded the data in sharepoint online lists. (i.e.)I have uploaded the data to several(7) lists in each subsites. I have 3 subsites. 
    I am getting this error "The remote server returned an error 503 server unavailable", while uploaded the data into lists. 
    Full Error Message:
    Message - The remote server returned an error 503 server unavailable.
    StackTrace -    at System.Net.HttpWebRequest.GetResponse()
    > cc525c: INFO]    at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
    > cc525c: INFO]    at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
    > cc525c: INFO]    at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
    > cc525c: INFO]    at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
    > cc525c: INFO]    at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
    This is not occur every time. Some time i didn't get any error data successfully uploaded in share point online list.
    Totally 4 hours taken uploaded the data into list for completed all 3 subsites. 
    If anyone know how to resolve this.
    Thanks,
    A.Ramu

    Hi,
    Per my understanding, there is an issue when uploading data from SQL Azure database to a SharePoint list in Online environment.
    For narrowing down the issue, I suggest you create a Console Application in Visual Studio without accessing the SQL Azure database and upload some sample data to the same SharePoint
    list to see if the issue still occurs intermittently.
    Thanks
    Patrick Liang
    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
    [email protected]

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

    We are attempting to upload a file to SharePoint on Office 365 and get the following error:
    The remote server returned an error: (401) Unauthorized.
    We also tried using NetworkCredentials and that got the following error: The remote server returned an error: (404) Not Found.
    The code is shown below.
    Any idea on to fix this error?
    public
    void uploadDocument(string
    siteurl, string username,
    SecureString securepassword,
    string domain,
    string filestreamPath =
    "NewDocument.docx",
    string serverRelativeUrl =
    "/Shared Documents/NewDocument.docx")
    ClientContext context =
    new
    ClientContext(siteurl);
            //context.Credentials = new NetworkCredential(username, securepassword, domain);
    context.Credentials = new
    SharePointOnlineCredentials(username, securepassword);
    using (FileStream
    fileStream =
    new
    FileStream(filestreamPath,
    FileMode.Open))
    ClientOM.File.SaveBinaryDirect(context,
    serverRelativeUrl, fileStream, true);

    Yes, it has access.  In fact, it has no problem getting the site properties using the code below.  It is just when I am uploading a file that the error occurs.
    public Web getProperties(string
    siteurl, string username,
    SecureString securepassword)
    Web web = null;
    // Starting with ClientContext, the constructor requires a URL to the
    // server running SharePoint.
    ClientContext context = new ClientContext(siteurl);
    // The SharePoint web at the URL.
    web = context.Web;
    // We want to retrieve the web's properties.
    context.Load(web);
    // Execute the query to the server.
    context.Credentials = new SharePointOnlineCredentials(username, securepassword);
    context.ExecuteQuery();
    return web;

Maybe you are looking for

  • POPUP after selecting button in ALV

    Hello everyone. I have an ALV (called with FM 'REUSE_ALV...') with a gui status of its own. I added a new button that must popup a window with information on some variables i just ended calculating. I allready tried using 'call screen' and the comman

  • Lumia 720 screen freeze

    Hi my new Lumia 720 sometimes freeze up and only way out is a reset..... Any tips please? Is this a known issue? Is there any fix update planned to be released?

  • Can I use a dataport in a motel with my new MacBook?

    I'm leaving this Saturday, could not find the answer. Please give me your advice. Thanks, Granny.

  • SRM PO Changes

    Hello, I have a requirement where I need to read the PO details, get the WBS Element & replace the WBS Element with a new one which I would have on my selection screen. Now, I am little new to SRM and I believe the coding in SRM will be different tha

  • Bigtime Problems With Volume Mounts

    Dear kind, helpful, charitable, community of Apple users, I'm been spinning my wheels on this for a week now and I'm totally stuck. I'm sufficiently desperate that I thought about offering a cash bounty via PayPal. (But I can't figure out an equitabl