AnsweredAssumed Answered

Social API

Question asked by greenawayr Champion on Oct 10, 2018

Hi,

 

I'm trying to workflow the process of following a document or site using the Social api.

 

I'm just wondering if anyone has done this and if so, could they give me a quick walkthrough. I'm currently hitting Forbidden issues with my Web Request using the URL

https://weburl/_api/social.following/

I put this into chrome and get XML, so just to try and progress things I'm putting this XML into a Query in line with Caroline Jung blog post on using REST API but this doesn't return a result.

 

Not a good start, so just wondering if anyone has tried this before, someone with a better understanding of the social api than me!

 

UPDATE

I've sorted an element of this out I think. Doing the GET against /_api/social.following now returns XML as shown below.

Response status code: 200

Response content:
<?xml version="1.0" encoding="utf-8"?><entry xml:base="https://sharepoint/site/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"><id>https://sharepoint/site/_api/social.following/my/following</id><category term="SP.Social.SocialRestFollowingManager" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" href="social.following/my/following" /><title /><updated>2018-10-10T13:42:41Z</updated><author><name /></author><content type="application/xml"><m:properties><d:MyFollowedDocumentsUri m:null="true" /><d:MyFollowedSitesUri m:null="true" /><d:SocialActor m:null="true" /></m:properties></content></entry>
Response headers:
Transfer-Encoding=chunked
X-SharePointHealthScore=0
SPClientServiceRequestDuration=5
SPRequestGuid=3f06979e-6118-b0ea-9a52-34d6111b0b7e
request-id=3f06979e-6118-b0ea-9a52-34d6111b0b7e
X-FRAME-OPTIONS=SAMEORIGIN
Persistent-Auth=true
MicrosoftSharePointTeamServices=15.0.0.4919
X-Content-Type-Options=nosniff
X-MS-InvokeApp=1; RequireReadOnly
Connection=close
Cache-Control=private, max-age=0
Content-Type=application/atom+xml;type=entry;charset=utf-8
Date=Wed, 10 Oct 2018 13:42:41 GMT
Expires=Tue, 25 Sep 2018 13:42:41 GMT
Last-Modified=Wed, 10 Oct 2018 13:42:41 GMT
Server=Microsoft-IIS/8.5
WWW-Authenticate=Negotiate oYGzMIGwoAMKAQChCwYJKoZIgvcSAQICooGbBIGYYIGVBgkqhkiG9xIBAgICAG+BhTCBgqADAgEFoQMCAQ+idjB0oAMCAReibQRriTYplgqtpWtJdwrF4Mi1tRO3Ilo6LWS0417hf5B0Ibv3ZScO5OoHXvgPiUPXcaE9LfvZGS0IsP88ksV1c2fZIuYGZskCUCngjwgnxyMXwJrZrzt7PjXgZ2WU7Q7EsiIkywo445Kya68fojs=
X-AspNet-Version=4.0.30319
X-Powered-By=ASP.NET

Response cookies:

I query this with the XPath //*[local-name()='FormDigestValue']

I then try to POST to the url

Web URL/_api/social.following/follow(ActorType=1,ContentUri=Item URL,Id=null)

This gives me a forbidden error, the ULS error logs contain the following.

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.

A quick google suggests that the Request Digest is invalid, as I know the credentials are not a problem. I'm not entirely sure what I'm looking for in the above XML, so can anyone say whether that's what I should be seeing and whether the XPath I'm using is correct. 

 

Thanks

Outcomes