SharePoint 2010 REST API JQUEry 插入、更新、删除 [英] SharePoint 2010 REST API JQUery Insert, Update, Delete

查看:70
本文介绍了SharePoint 2010 REST API JQUEry 插入、更新、删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释或指向包含使用 Jquery 和 SharePoint 2010 Rest API 执行更新、删除的示例的链接吗?

Can anyone explain or point me to a link with samples of doing Update, Delete using Jquery with the SharePoint 2010 Rest API?

我有插入工作,当然还有查询,因为 MSDN 文档解释了网络上的每个教程都解释了查询,但只是想知道是否有人插入、更新、删除数据,而不仅仅是关于查询的示例和教程?是的,我知道我可以使用 CSOM,但我想了解这是如何通过 jquery 和 sharepoint rest 完成的?

I have the insert working and of course queries since the MSDN documentation explains and every tutorial on the net explains queries but just wondering if anyone ever inserts, updates, deletes data instead of only samples and tutorials on querying? Yes I know I can use the CSOM but I want to learn how this is done via jquery and sharepoint rest?

我也想使用 Merge 进行更新.

Also I want to use Merge for updating.

这是有效的插入代码:

function insertMilestone() {
            var mileStonesListUrl = "/_vti_bin/listdata.svc/Milestones";    
               var milestone = {};
               milestone.Title = "Testing from REST";

               var entry = JSON.stringify(milestone);

               $.ajax({
                   type: "POST",
                   url: mileStonesListUrl,
                   data: entry,
                   contentType: "application/json; charset=utf-8",
                   error: function (xhr) {
                       alert(xhr.status + ": " + xhr.statusText);
                   },

                   success: function () {
                       getAll();

                   }
               });
           }

推荐答案

我最近使用了 SP 2013 的 REST API,作为一个示例 POC,可用于任何调用实现,即 JQuery、C# 等.

I recently worked with the REST API for SP 2013, as a Example POC that can be used for any call implementation i.e. JQuery, C# etc.

使用邮递员

首先获取您的摘要令牌:

在这个网站上找到了一个方法:http://tech.bool.se/basic-rest-request-sharepoint-using-postman/[信用到期的信用]

A method was found on this site : http://tech.bool.se/basic-rest-request-sharepoint-using-postman/​ [Credit where credit is due]

发布

http://<SharePoint Domain Url>/sites/<Site name>/_api/contextinfo

标题:

Accept : application/json;odata=verbose

身体:清体

从有效负载使用FormDigestValue"值,并在执行更改 SharePoint 中项目的操作时将其放入带有键的标题中:X-RequestDigest.

From the payload use "FormDigestValue" value and put it into your headers with the key : X-RequestDigest when making actions that alter items in SharePoint.

读取数据:

获取

http://<SharePoint Domain Url>/sites/<Site name>/_api/web/getfolderbyserverrelativeurl('/Sites/<Site Name>/Shared Documents/My Folder')/files?$select=Name

标题:

Accept : application/json;odata=verbose​

当涉及到创建、更新、删除时,您需要摘要令牌或授权令牌来执行这些操作,该令牌在开始检索时突出显示.

When it comes to create, update , delete you need the digest token or an authorization token to perform these actions, this token is highlighted at the begining to to retrieve.

创建数据发布

http://<SharePoint Domain Url>/sites/<Site Name>/_api/web/folders​

标题:

Accept : application/json;odata=verbose

X-RequestDigest : 'GUID looking toking'

Content-Type : application/json;odata=verbose

身体:

{ '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': '/Sites/<Site Name>/Shared Documents/Some Folder/POC3'}​

注意:'ServerRelativeUrl'末尾POC3的文件夹就是我要创建的文件夹

相关资源:http://msdn.microsoft.com/en-us/library/office/fp142380(v=office.15).aspx

注意: PostMan 用于此示例,其他应用程序可能需要您对端点进行 url 编码.

Note: PostMan was used for this example and other application may need you to url encode the endpoint.

以上请求结构可用于所有请求,相关资源重点介绍了一些可与 REST Api 一起使用的标准方法

The above Request Structure can be used for all requests, the related resource highlights some of the standard methods that can be used with the REST Api

这篇关于SharePoint 2010 REST API JQUEry 插入、更新、删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆