Sharepoint 2013-REST-API-Aufruf mit C#

Dies ist ein follow-up-Frage zu einem meine frühere Frage in Stackoverflow.

Ich versuche eine Verbindung zu Sharepoint Online Voraussetzung, um Dokumente im "Dokumenten Bibliothek" mit Hilfe der HTTPClient und die Sharepoint 2013-REST-API.

Alles was ich hier mache ist eine Einfache, Anonyme HTTP-GET-Aufruf mit HttpClient.

Der code ist wie folgt :

System.Net.Http.HttpClient _Client = new System.Net.Http.HttpClient();
_Client.BaseAddress = new Uri("https://test.sharepoint.com/_vti_bin/ListData.svc");
_Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/atom+xml"));
_Client.DefaultRequestHeaders.Add("auth_user", "[email protected]");
_Client.DefaultRequestHeaders.Add("auth_pass", "test");
_Client.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose");
HttpResponseMessage resp = _Client.GetAsync(new Uri("https://test.sharepoint.com/_vti_bin/ListData.svc/Documents()")).Result;
string respString = resp.Content.ReadAsStringAsync().Result;

Und ich erhalte die folgende Fehlermeldung:

Nicht zum Lesen von Daten aus dem transport-Verbindung: Die Verbindung wurde geschlossen.

Stack-Trace ist wie folgt :

[IOException: Unable to read data from the transport connection: The connection was closed.]
   System.Net.ConnectStream.EndRead(IAsyncResult asyncResult) +6501654
   System.Net.Http.WebExceptionWrapperStream.EndRead(IAsyncResult asyncResult) +30
   System.Net.Http.StreamToStreamCopy.BufferReadCallback(IAsyncResult ar) +54

[HttpRequestException: Error while copying content to a stream.]

[AggregateException: One or more errors occurred.]
   System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) +3569193
   System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) +73
   System.Threading.Tasks.Task`1.get_Result() +10522673
   WebApp.Test.Page_Load(Object sender, EventArgs e) in @Location
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

Ich gegangen durch verschiedene blogs/Artikel zu bekommen, irgendeine Idee um das Problem zu lösen.Aber ich cudn keine Lösung.

Irgendwelche Gedanken zu dieser?

  • Tun Sie dies innerhalb eines ASP.NET web-site? Ich vermute, etwas seltsam ist Los mit Ihr .Das Ergebnis nennen. Haben Sie versucht, mit async/await ?
  • Ja,ich Tue dies aus einem ASP.NET website.
InformationsquelleAutor Bisileesh | 2013-11-04
Schreibe einen Kommentar