none
Getting error: Unexpected response from the server. The content type of the response is "text/html; charset=utf-8"

    Question

  • hi,

    I am using different clientcontext from two different O365 URL's, suppose as sourceClientContext and targetClientContext.

    and I am trying to load all lists from source site. so that Im using 

    sourceClientContext.Load(sourceClientContext.Web.Lists); sourceClientContext.ExecuteQuery();

    on ExecuteQuery statement giving me following error,

    Microsoft.SharePoint.Client.ClientRequestException was caught
      HResult=-2146233088
      Message=Unexpected response from the server. The content type of the response is "text/html; charset=utf-8". The status code is "OK".
      Source=Microsoft.SharePoint.Client.Runtime
      StackTrace:
           at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
           at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
           at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
           at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
           at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
           at ManagedDataMigrator.SiteMigrator.btnLoadSite_Click(Object sender, EventArgs e) in


    And when I am trying to execute same code with two same sitecollection's subsite then it works fine. Dont know what I am missing.. 

    Anybody please help?

    thanks in advance,

    Wednesday, November 21, 2012 6:20 AM

All replies

  • UPdate:

    After lots of time I found that,

    1. I have first authenticated sourceClientContext and then secondly targetClientContext.

    when I am trying to execute 

    sourceClientContext.Load(sourceClientContext.Web.Lists); sourceClientContext.ExecuteQuery(); code then I am getting Error message: Unexpected response from the server. The content type of the response is "text/html; charset=utf-8". The status code is "OK".

    and if I replace above line with targetClientContext.Load(targetClientContext.Web.Lists); targetClientContext.ExecuteQuery();

    then its working fine. 

    Can anybody please tell me why? and what is the solution for above problem?

    Wednesday, November 21, 2012 6:47 AM