4

私は .NET Web アプリケーションで作業しています。Sharepoint Online Premise に接続して、HTTPClient と Sharepoint 2013 REST API を使用して「ドキュメント ライブラリ」のドキュメントを取得しようとしています。

このため、ブラウザで次の残りのサービスをテストしました。

   https://site_url/_vti_bin/ListData.svc/Documents

これは、特定の Web サイトのドキュメント ライブラリに存在するすべてのドキュメントのメタデータを提供します。

サービスURLへの参照を追加し、次のコードを使用して、プログラムで同じことをしようとすると、

TestSiteDataContext ctx = new TestSiteDataContext(new Uri("https://site url/_vti_bin/ListData.svc"));
ctx.Credentials = new NetworkCredential("test@test.onmicrosoft.com", "test");
var data = ctx.Documents.ToList();

次の例外が発生します: 「リクエストは中止されました: SSL/TLS セキュア チャネルを作成できませんでした。」スタック トレースは次のとおりです。

at System.Net.HttpWebRequest.GetResponse()
   at System.Data.Services.Client.QueryResult.Execute()
   at System.Data.Services.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
   at System.Data.Services.Client.DataServiceQuery`1.Execute()
   at System.Data.Services.Client.DataServiceQuery`1.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at SPO_AccessAWebService.Program.Main(String[] args) in Location\Program.cs:line 35
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

これに対する解決策を見つけるために、さまざまな記事/ブログを調べました.Bustは何も見つかりませんでした. による認証を示すさまざまなサンプルを見ることができました。

ctx.Credentials = CredentialCache.DefaultNetworkCredentials;

これも同じエラーをスローしています。

SharePoint 2013 REST API を認証する他の方法はありますか?

この問題を解決するための洞察を誰かに提供してもらえますか?

4

1 に答える 1