当前位置:网站首页>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 .

边栏推荐
- Detailed explanation of tool classes countdownlatch and cyclicbarrier of concurrent programming learning notes
- 五、图像像素统计
- mysql插入百万数据(使用函数和存储过程)
- 【Transformer】SegFormer:Simple and Efficient Design for Semantic Segmentation with Transformers
- 【语义分割】语义分割综述
- clion+opencv+aruco+cmake配置
- The differences and reasons between MySQL with and without quotation marks when querying string types
- 主流实时流处理计算框架Flink初体验。
- 并发编程学习笔记 之 原子操作类AtomicInteger详解
- PyTorch基础知识(可入门)
猜你喜欢

nacos外置数据库的配置与使用

The third week of postgraduate freshman training: resnet+resnext

PyTorch的数据读取机制

FFmpeg创作GIF表情包教程来了!赶紧说声多谢乌蝇哥?

How to obtain openid of wechat applet in uni app project

【网络设计】ConvNeXt:A ConvNet for the 2020s

【Transformer】TransMix: Attend to Mix for Vision Transformers

Flink, the mainstream real-time stream processing computing framework, is the first experience.

mysql 的show profiles 使用。

并发编程学习笔记 之 ReentrantLock实现原理的探究
随机推荐
Flutter正在被悄悄放弃?浅析Flutter的未来
【Transformer】AdaViT: Adaptive Vision Transformers for Efficient Image Recognition
【pycharm】pycharm远程连接服务器
【Transformer】ACMix:On the Integration of Self-Attention and Convolution
tensorboard使用
nacos外置数据库的配置与使用
第一周任务 深度学习和pytorch基础
IDEA中设置自动build-改动代码,不用重启工程,刷新页面即可
Anr Optimization: cause oom crash and corresponding solutions
【目标检测】Generalized Focal Loss V1
有价值的博客、面经收集(持续更新)
SSM integration
[tensorrt] convert pytorch into deployable tensorrt
第2周学习:卷积神经网络基础
fastText学习——文本分类
[DL] build convolutional neural network for regression prediction (detailed tutorial of data + code)
FFmpeg创作GIF表情包教程来了!赶紧说声多谢乌蝇哥?
并发编程学习笔记 之 Lock锁及其实现类ReentrantLock、ReentrantReadWriteLock和StampedLock的基本用法
Activity交互问题,你确定都知道?
【Transformer】SegFormer:Simple and Efficient Design for Semantic Segmentation with Transformers