While working with SharePoint REST API services, sometimes POST call is having issues with using form digest (code: $("#__REQUESTDIGEST").val()). In these cases, need to generate the form digest based on context and below code is for it,
return getFormDigest().then(function (digestval) {
return $.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/contextinfo",
method: "POST",
headers: { "Accept": "application/json; odata=verbose" }
});
});
No comments:
Post a Comment