Wpf OData V4访问安全URI
我需要开发一个WPF应用程序,它使用ProjectOnline服务器的OData服务。当我尝试用ODataLib V4引用OData服务时,它不起作用,因为OData服务是安全的 有人知道这个问题的解决方法吗?我找到了解决方法Wpf OData V4访问安全URI,wpf,odata,Wpf,Odata,我需要开发一个WPF应用程序,它使用ProjectOnline服务器的OData服务。当我尝试用ODataLib V4引用OData服务时,它不起作用,因为OData服务是安全的 有人知道这个问题的解决方法吗?我找到了解决方法 在xml文件中提取Project Online的元数据(pwa站点]/\u api/ProjectData/$metadata) 将xml文件的扩展名更改为.edmx 在框架目录(DataSvcUtil/in:edmxfile.edmx/out:csfile.cs/lan
- Microsoft.SharePoint.Client
- Microsoft.SharePoint.Client.DocumentManagement
- Microsoft.SharePoint.Client.Publishing
- Microsoft.SharePoint.Client.Runtime
- Microsoft.SharePoint.Client.Runtime.Windows
- Microsoft.SharePoint.Client.Taxonomy
- Microsoft.SharePoint.Client.UserProfiles
- Microsoft.SharePoint.Client.WorkflowServices
- Microsoft.SharePoint.WorkflowServices.Activities
- Microsoft SharePoint Solutions Framework
private const string PSDATA = "https://[your pwa site]";
ProjectOData.ReportingData context =
new ProjectOData.ReportingData(new Uri(PSDATA + "/_api/ProjectData/", UriKind.Absolute)) { IgnoreMissingProperties = true };
var username = <username>;
var password = <password>;
var secureString = new System.Security.SecureString();
foreach (char c in password.ToCharArray())
{
secureString.AppendChar(c);
}
context.Credentials = new SharePointOnlineCredentials(username, secureString);
SharePointOnlineCredentials credentials = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(username, secureString);
var authenticationCookie = credentials.GetAuthenticationCookie(new Uri(PSDATA));
context.SendingRequest += delegate (object sender, SendingRequestEventArgs e)
{
e.RequestHeaders.Clear();
e.RequestHeaders.Add("Cookie", authenticationCookie);
};
var projectQuery1 = from p in context.Projects
select p;
private const string PSDATA=“https://[您的pwa站点]”;
ProjectOData.ReportingData上下文=
新的ProjectOData.ReportingData(新的Uri(PSDATA+“/\u api/ProjectData/”,UriKind.Absolute)){IgnoreMissingProperties=true};
var用户名=;
var密码=;
var secureString=new System.Security.secureString();
foreach(password.ToCharArray()中的字符c)
{
AppendChar(c);
}
context.Credentials=新的SharePointOnlineCredentials(用户名、secureString);
SharePointOnlineCredentials credentials=新的Microsoft.SharePoint.Client.SharePointOnlineCredentials(用户名,secureString);
var authenticationCookie=credentials.GetAuthenticationCookie(新Uri(PSDATA));
context.SendingRequest+=委托(对象发送方,SendingRequestEventArgs e)
{
e、 RequestHeaders.Clear();
e、 添加(“Cookie”,authenticationCookie);
};
var projectQuery1=来自context.Projects中的p
选择p;