当前位置:网站首页>C connect to SharePoint online webservice
C connect to SharePoint online webservice
2022-07-29 06:05:00 【Denny Hui】
Use Sharepoint Client Object model for data reading :
ClientContext clientContext = new ClientContext(ConfigHelper.GetConfigStr("SharepointOnlineURL"));
string strPassWord = ConfigHelper.GetConfigStr("SharepointOnlinePW");
char[] pChar = strPassWord.ToCharArray();
SecureString password = new SecureString();
foreach (char c in pChar)
{
password.AppendChar(c);
}
clientContext.Credentials = new SharePointOnlineCredentials(ConfigHelper.GetConfigStr("SharepointOnlineUser"), password);
List a = clientContext.Web.Lists.GetByTitle(" Mail distribution definition ");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name=\"UseJob\"></FieldRef><Value Type=\"Text\">" + JobName + "</Value></Eq></Where></Query></View>";
Microsoft.SharePoint.Client.ListItemCollection Listitems = a.GetItems(camlQuery);
clientContext.Load(
Listitems,
items => items
.Include(
item => item["ReportName"],
item => item["Addressee"],
item => item["UseJob"],
item => item["ExcelName"],
item => item["AccountNumber"]
));
clientContext.Load(Listitems);
clientContext.ExecuteQuery();
DataTable dt = new DataTable();
dt.Columns.Add("ReportName", Type.GetType("System.String"));
dt.Columns.Add("Addressee", Type.GetType("System.String"));
dt.Columns.Add("UseJob", Type.GetType("System.String"));
dt.Columns.Add("ExcelName", Type.GetType("System.String"));
dt.Columns.Add("AccountNumber", Type.GetType("System.String"));
foreach (Microsoft.SharePoint.Client.ListItem listItem in Listitems)
{
DataRow newRow;
newRow = dt.NewRow();
newRow["ReportName"] = listItem["ReportName"].ToString();
newRow["Addressee"] = listItem["Addressee"].ToString();
newRow["UseJob"] = listItem["UseJob"].ToString();
newRow["ExcelName"] = listItem["ExcelName"].ToString();
newRow["AccountNumber"] = listItem["ExcelName"].ToString();
dt.Rows.Add(newRow);
}
string result = JsonConvert.SerializeObject(dt);
return result;In fact, the most important authentication credentials , Verification methods and methods WebService It's a little different :
clientContext.Credentials = new SharePointOnlineCredentials(ConfigHelper.GetConfigStr("SharepointOnlineUser"), password);It's using :SharePointOnlineCredentials
For more articles, please scan the code and follow the official account , If you have problems, you can also raise them on the official account .

边栏推荐
- Rsync+inotyfy realize real-time synchronization of single data monitoring
- Detailed explanation of MySQL statistical function count
- ROS教程(Xavier)
- [DL] build convolutional neural network for regression prediction (detailed tutorial of data + code)
- Nailing alarm script
- ASM插桩:学完ASM Tree api,再也不用怕hook了
- 迁移学习——Robust Visual Domain Adaptation with Low-Rank Reconstruction
- 虚假新闻检测论文阅读(一):Fake News Detection using Semi-Supervised Graph Convolutional Network
- Tear the ORM framework by hand (generic + annotation + reflection)
- ANR优化:导致 OOM 崩溃及相对应的解决方案
猜你喜欢

【图像分类】如何使用 mmclassification 训练自己的分类模型

【Attention】Visual Attention Network

迁移学习——Robust Visual Domain Adaptation with Low-Rank Reconstruction

【语义分割】Mapillary 数据集简介

How to obtain openid of wechat applet in uni app project

【目标检测】6、SSD

第三周周报 ResNet+ResNext

迁移学习—— Transfer Feature Learning with Joint Distribution Adaptation

GAN:生成对抗网络 Generative Adversarial Networks

mysql插入百万数据(使用函数和存储过程)
随机推荐
Detailed explanation of atomic operation class atomicinteger in learning notes of concurrent programming
[pycharm] pycharm remote connection server
虚假新闻检测论文阅读(一):Fake News Detection using Semi-Supervised Graph Convolutional Network
Spring, summer, autumn and winter with Miss Zhang (1)
并发编程学习笔记 之 工具类Semaphore(信号量)
Exploration of flutter drawing skills: draw arrows together (skill development)
简单聊聊 PendingIntent 与 Intent 的区别
Basic use of array -- traverse the circular array to find the maximum value, minimum value, maximum subscript and minimum subscript of the array
Centos7 silently installs Oracle
[semantic segmentation] overview of semantic segmentation
【CV】请问卷积核(滤波器)3*3、5*5、7*7、11*11 都是具体什么数?
【目标检测】6、SSD
fastText学习——文本分类
mysql 的show profiles 使用。
Semaphore (semaphore) for learning notes of concurrent programming
C # judge whether the user accesses by mobile phone or computer
【Transformer】ATS: Adaptive Token Sampling For Efficient Vision Transformers
Android Studio 实现登录注册-源代码 (连接MySql数据库)
mysql插入百万数据(使用函数和存储过程)
Anr Optimization: cause oom crash and corresponding solutions