How to update a Hyperlink field using REST API in SharePoint 2013
below code snippet helps to update the Hyper link filed in SharePoint 2013 using REST API
$.ajax
({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/site/rootweb/lists/GetByTitle('ListName')/items",
type: "POST",
headers:
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "POST"
},
data: JSON.stringify
({
__metadata:
{
type: "SP.Data.ListnameListItem"
},
Link:{Url: 'http://google.com', Description:'Google'}
}),
success: function(data, status, xhr)
{ // alert('success');
},
error: function(xhr, status, error)
{
//$("#ResultDiv").empty().text(data.responseJSON.error);
}
});
$.ajax
({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/site/rootweb/lists/GetByTitle('ListName')/items",
type: "POST",
headers:
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "POST"
},
data: JSON.stringify
({
__metadata:
{
type: "SP.Data.ListnameListItem"
},
Link:{Url: 'http://google.com', Description:'Google'}
}),
success: function(data, status, xhr)
{ // alert('success');
},
error: function(xhr, status, error)
{
//$("#ResultDiv").empty().text(data.responseJSON.error);
}
});
Comments
Post a Comment