Rest API
How to update Document Set properties using REST API in SharePoint 2013

Update Document Set using REST API in SharePoint 2013

You can perform essential create, read, update, and delete (CRUD) operations by REST API in SharePoint 2013. The REST interface exposes all the SharePoint entities and services available in the other SharePoint client APIs. One advantage of using REST is that you don’t have to add references to any SharePoint libraries or client assemblies. Instead, you make HTTP requests to the appropriate endpoints to retrieve or update SharePoint entities, such as webs, lists, and list items.

<script src=”https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js” type=”text/javascript”></script>
<script>

function executeJson(url,method,additionalHeaders,payload)
{
if(method == “GET”) {
return $.ajax
({
url: url,
type: method,
headers: {
“accept”: “application/json;odata=verbose”,
},
success: function(data)
{
return data;
},
error: function(error)
{
alert(JSON.stringify(error));
}
});
}
if(method == “POST”) {
return $.ajax
({
url: url, // list item ID
type: method,
data: JSON.stringify(payload),
headers: {
“Accept”: “application/json;odata=verbose”,
“Content-Type”: “application/json;odata=verbose”,
“X-RequestDigest”: $(“#__REQUESTDIGEST”).val(),
“X-HTTP-Method”: “MERGE”,
“If-Match”: “*”
},
success: function(data, status, xhr)
{
},
error: function(xhr, status, error)
{
alert(JSON.stringify(error));
}
});
}
}

function renameFolder(webUrl,folderUrl,name)
{
var folderItemUrl = webUrl + “/_api/web/GetFolderByServerRelativeUrl(‘” + folderUrl + “‘)/ListItemAllFields”;
executeJson(folderItemUrl,”GET”).success(function(data){
UpdateValue(data,name)
});
}

function UpdateValue(data,name){
debugger;
var itemPayload = {};
itemPayload[‘__metadata’] = {‘type’: data.d[‘__metadata’][‘type’]};
itemPayload[‘Title’] = name;
var itemUrl = data.d[‘__metadata’][‘uri’];
var additionalHeaders = {};
additionalHeaders[“X-HTTP-Method”] = “MERGE”;
additionalHeaders[“If-Match”] = “*”;
console.log(itemPayload);
return executeJson(itemUrl,”POST”,additionalHeaders,itemPayload);
}

function Folder(){
renameFolder(“siteurl”,’pathtoDocumentSet’,’ValuetoChange’).done(function()
{
console.log(‘Folder has been renamed’);
})
.fail(
function(error){
console.log(JSON.stringify(error));
});
}

</script>

<button onclick=”Folder()”>Click me</button>

The above given code will help you to Update Document Set using REST API.

For any query Contact us or email us to [email protected]

SharePoint-2013
How to Get All Users From Site Group in SharePoint 2013 Using REST API
How to populate a drop down with all the users from a Site Group in SharePoint 2013 on premise Using REST API

In this article you will see how to get all the users from a site group using the REST API in SharePoint 2013 Online.

Introduction

SharePoint 2013 introduces a Representational State Transfer (REST) service that is comparable to the existing SharePoint client object models. Share point allows the developers to interact remotely with SharePoint data using any technology that supports REST web requests. Developers can perform Create, Read, Update, and Delete (CRUD) operations.

From their apps for SharePoint, solutions, and client applications, they are using REST web technologies and standard Open Data Protocol (OData) syntax. In this article, you will see the following.

  • Create an app using NAPA Tool in SharePoint 2013 Online.
  • Cross-Domain Requests.
  • Get all the users from the host site group using the REST API.

Source Code:

<script src=”../SiteAssets/jquery-1.11.3.js”></script>
<script type=”text/javascript”>
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + “/_api/web/sitegroups/getByName(‘GroupName’)/users”,
type: “GET”,
headers: {“accept”: “application/json;odata=verbose”},
success: function (data){
if (data.d.results)
{
for (var i = 0; i < data.d.results.length; i++) {

//Loop through all users and binding in dropdown
if (data.d.results[i] != null && data.d.results[i] != undefined) {
if ($(“#ddlGroup option[value='” + data.d.results[i] + “‘]”).length == 0) {
$(‘#ddlGroup’).append($(“<option/>”, {
value: data.d.results[i].Email,
text: data.d.results[i].Title
}));
}
}
}
}
},
error: function (error) {
alert(JSON.stringify(error));
}
});
</script>

Summary

Thus in this article you saw how to get all the users from a site group using the REST API in SharePoint 2013 Online.

For any query or solution you can contact us or email us for solution. Check our website for more such content.

About Us

We create experiences that change the way people interact with brands – and with each other

Newsletter