403 error while posting to Sharepoint REST social API
I am having a problem with Sharepoint Rest social API. Here's the code to
like a post I got from googling around
function likePost() {
var postId =
'1.0f435d74164149cfa76e19ad21dc7c2e.8a7874906a9348189f2fb83295b598d5.06ff4087162c48dcb43828e4ddf82c38.98b9fc73d5224265b039586688b15b98.8ec3fc561f084e6b98bfb117e9c23022.64.64.1';
$.ajax( {
url: "/_api/social.feed/Post/Like",
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
},
data: JSON.stringify({
'ID': postId
}),
success: function (data) {
alert("Success");
var jsonObject = data.d.ID;
alert(jsonObject);
},
error: function (xhr, ajaxOptions, thrownError) {
alert("POST error:\n" + xhr.status + "\n" + thrownError);
}
});
}
However when I try this on my Sharepoint site, I always get 403 FORBIDDEN
error. Any help would be appreciated.
No comments:
Post a Comment