SharePoint REST API
来源:互联网 发布:php小例子 编辑:程序博客网 时间:2024/05/16 10:31
博客地址:http://blog.csdn.net/FoxDave
本篇主要讲解如何应用$batch查询选项来批量执行REST/OData请求,它将多个操作捆绑到一个请求中,可以改进应用程序的性能。
$batch选项执行摘要
SharePoint Online(也包括SharePoint 2016)和Office 365的API实现了OData的$batch查询选项,下面罗列了一些主要的点:
1. 请求URL由根服务URL和$batch选项构成,例如https://fabrikam.sharepoint.com/_api/$batch或https://fabrikam.office365.com/api/v1.0/me/$batch。
2. HTTP请求的MIME类型为multipart/mixed。
3. 请求的body被请求头的边界字符串分割成了相对独立的部分。
4. 请求body的每个部分有自己的HTTP动作符和REST URL,还有内部的body。
5. 一个部分可以是读操作或写操作的变更集合或函数调用。变更集合本身的MIME类型是multipart/mixed,它里面的部分包含插入、更新或删除操作。
6. 最后一点需要注意,不支持“全部或没有”这种表达,变更集合中的操作是相对独立的,任何失败的部分都不会影响其他的,并且也不会回滚,这一点在开发的时候需要留意。
代码示例
C#:OfficeDev/Core.ODataBatch
JavaScript:andrewconnell/sp-o365-rest
请求和响应的示例
下面是一个带有两个GET操作的HTTP请求从两个不同列表获取列表项标题的请求和响应示例。
POST https://fabrikam.sharepoint.com/_api/$batch HTTP/1.1Authorization: Bearer <access token omitted>Content-Type: multipart/mixed; boundary=batch_e3b6819b-13c3-43bb-85b2-24b14122fed1Host: fabrikam.sharepoint.comContent-Length: 527Expect: 100-continue--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1Content-Type: application/httpContent-Transfer-Encoding: binaryGET https://fabrikam.sharepoint.com/_api/Web/lists/getbytitle('Composed%20Looks')/items?$select=Title HTTP/1.1--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1Content-Type: application/httpContent-Transfer-Encoding: binaryGET https://fabrikam.sharepoint.com/_api/Web/lists/getbytitle('User%20Information%20List')/items?$select=Title HTTP/1.1--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1--下面是带有一个DELETE操作和一个GET操作的请求示例
POST https://fabrikam.sharepoint.com/_api/$batch HTTP/1.1Authorization: Bearer <access token omitted>Content-Type: multipart/mixed; boundary=batch_7ba8d60b-efce-4a2f-b719-60c27cc0e70eHost: fabrikam.sharepoint.comContent-Length: 647Expect: 100-continue--batch_7ba8d60b-efce-4a2f-b719-60c27cc0e70eContent-Type: multipart/mixed; boundary=changeset_efb6b37c-a5cd-45cb-8f5f-4d648006e65d--changeset_efb6b37c-a5cd-45cb-8f5f-4d648006e65dContent-Type: application/httpContent-Transfer-Encoding: binaryDELETE https://fabrikam.sharepoint.com/_api/Web/lists/getbytitle('OldList') HTTP/1.1If-Match: "1"--changeset_efb6b37c-a5cd-45cb-8f5f-4d648006e65d----batch_7ba8d60b-efce-4a2f-b719-60c27cc0e70eContent-Type: application/httpContent-Transfer-Encoding: binaryGET https://fabrikam.sharepoint.com/_api/Web/lists HTTP/1.1--batch_7ba8d60b-efce-4a2f-b719-60c27cc0e70e--感兴趣想了解更多关于OData库信息的可以访问官网。
SharePoint REST接口部分的讲述就到这里。
- SharePoint之rest api
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint REST API
- SharePoint 2013 Search REST API 使用示例
- SharePoint 2013 Excel Services REST API介绍
- SharePoint rest api VS 取出来时间不一致问题
- Rest Api how to retrieve list items from SharePoint Online
- 项目分栏
- easyui
- 质因数分解
- PHP
- java8的一些应用
- SharePoint REST API
- Python库--numpy学习笔记总结
- Linux的scp跨服务器复制
- 将指定文件夹里的文件打包为zip
- UVA 11248 Frequency Hopping
- 每天一道LeetCode-----括号匹配
- Spark2.2 SparkContext原理剖析图及源码
- 批量删除
- 406. Queue Reconstruction by Height