sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

/_api/social.following errors with /isfollowed and /my/followed documents

Open Hermitude opened this issue 6 years ago • 26 comments

(First time user of GitHub, please forgive any errors)

Category

  • [ ] Bug

Describe the bugs

I've been using the example code for following/unfollowing documents from SocialRestFollowingManager resource ( /_api/social.following) successfully for several months in the Sharepoint Online environment. I'm applying this in a classic site content editor webpart as well as on a modern page using spfx field customizer extension.

Over the last week I have experienced the following issues:

  1. 404 errors for all /_api/social.following/isfollowed calls
  2. /_api/social.following/my/followed(types=2) is returning sites instead of documents, and the scope is outside of the site I'm querying.

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Hermitude avatar Apr 27 '20 18:04 Hermitude

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Apr 27 '20 18:04 msft-github-bot

  1. For isfollowed endpoint, here is a sample to verify if current user followed a specific site:
<script src="https://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
    var item = {
		  "actor":{
		  "__metadata":{"type":"SP.Social.SocialActorInfo"},
		  "ActorType":2,
		  "ContentUri": "https://zheguo.sharepoint.com/"
		}    
		
	};

$( document ).ready(function() {
    $.ajax({
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/social.following/isfollowed",
        type: "POST",
        contentType: "application/json;odata=verbose",
        data: JSON.stringify(item),
        headers: {
            "Accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        },
        success: function (data) {
            console.log(data);
                        
        },
        error: function (data) {
            alert("Error");
            
        }
    });

});
</script>

The data returned:

Image 8

  1. ActorType 2 is standing for sites, please refer the following document:

SP.Social.SocialActorInfo.actorType property

This should be a typo in the document, please see the sample request body:

For document (ActorType:1)

Image 9

For Site (ActorType:2) Image 10

For Tag (ActorType:3)

Image 11

Jerry0527 avatar Apr 28 '20 09:04 Jerry0527

Hi, Thanks for your thorough response.

  1. I'm trying to get followed documents, not followed sites. Yes, I'm using Actor type 1.
  2. The types in my/followed is a different parameter than ActorTypes. No matter what type I try, it keeps returning sites.

Endpoint URI structure GET http:////_api/social.following/my/followed(types=15)

Request parameter types

Type: Int32

The actor types to include. Users = 1, Documents = 2, Sites = 4, Tags = 8. Bitwise combinations are allowed.

Hermitude avatar Apr 28 '20 13:04 Hermitude

I am also getting the same issue.

I have been using SharePoint online rest endpoint to get users to follow documents. The endpoint is {sitepath}/_api/social.following/my/followed(types=2) In the Same, I follow the Document using REST API Post method {sitepath}/_api/social.following/follow I was able to get follow docs in the response but from the last couple of DAYS, These endpoint has stopped working and not receiving the docs in response. Is there one else facing a similar issue or know about any outage on Microsoft side? Because the Same issue happened in all our client Tenants. FYI: This Query used in the APP Web. (SharePoint Hosted)

The Same issue happened across all my tenants. I have been checked more than 5 Tenants the same issue.

Please help to me Resolve this @andrewconnell @Hermitude @Jerry0527

Kamalasekaran avatar May 04 '20 06:05 Kamalasekaran

Hello, we are currently experiencing the same issues in at least 2 tenants.

  1. We are able to fetch "all" followed items but no longer by actortype enum. That is, all types=... except 14 or 15 result in only followed sites being returned.
  2. Calls to "follow" result in 200 but no new documents are followed when we fetch all followed items.

siljemda avatar May 05 '20 08:05 siljemda

I also had code working for months that can no longer use the isfollowed endpoint.

Code for reference:

        var data = JSON.stringify({
            "actor":{
                "__metadata":{
                    "type":"SP.Social.SocialActorInfo"
                },
                "ActorType":1,
                "ContentUri": docUrl,
                "Id":null
              }
        });

        var headers = {
            "accept": "application/json;odata=verbose",
            'content-type': 'application/json;odata=verbose',
            'X-RequestDigest': document.getElementById('__REQUESTDIGEST').value,
            credentials: 'same-origin'
        }

        fetch( followingManagerEndpoint + '/isfollowed', { 
            method: 'POST',
            headers: headers,
            body: data
        })

sethstevenson avatar May 06 '20 22:05 sethstevenson

I am also encountering this issue. The request to retrieve followed content does not return the correct data and following would result in a 404 error.

This has broken solutions in a few areas for my client.

Is there an estimated timeline for this to be resolves? Thanks all!

WaltBC avatar May 07 '20 01:05 WaltBC

@JeremyKelley ... possible change in REST API behavior?

andrewconnell avatar May 09 '20 12:05 andrewconnell

Hi I had find one workaround to get My followed documents using below URL

return $.ajax({
				url: webUrl + "/_api/social.following/my/followed(types=6)",
				type: "Get",
				processData: false,
				contentType: "application/json;odata=verbose",
				headers: { "Accept": "application/json; odata=verbose" },
			});

Once you received the response filter as shown below to get followed documents.

IsFollowed = true
CanFollow = false

akashpanjwani avatar May 14 '20 08:05 akashpanjwani

Thanks @akashpanjwani . Have you found any workarounds for /isfollowed?

Hermitude avatar May 14 '20 14:05 Hermitude

Hi @andrewconnell

Do we have a progress update into the investigation of this issue? If so is there a rough timeline for a resolution?

Thanks Andrew!

WaltBC avatar May 15 '20 06:05 WaltBC

@WaltBC nothing shared = nothing to share. If I learn something, I'll share :)

andrewconnell avatar May 15 '20 14:05 andrewconnell

Thanks @akashpanjwani . Have you found any workarounds for /isfollowed?

Yes we need to check from current user followed document whether exist or not.

akashpanjwani avatar May 18 '20 10:05 akashpanjwani

I've asked the team that owns this API if they have any ideas what might be going on here either they or I will come back with an update based on what they find.

Separately you can use the newly updated to 1.0 Microsoft Graph API for following / unfollowing sites. Follow Unfollow List followed sites

As best we can tell the result from the Microsoft Graph API is up to date as you follow and stop following sites.

JeremyKelley avatar May 21 '20 18:05 JeremyKelley

Thanks @JeremyKelley , note that the endpoint _/api/social.following/my/followed works for followed sites, but it has stopped working for followed documents

Rafaelki avatar May 21 '20 18:05 Rafaelki

I have found great success transitioning from the isFollowed and /my/followed endpoints to Graph as @JeremyKelley stated.

For docs, how about https://graph.microsoft.com/v1.0/me/drive/following? I have found this to work well and it includes followed docs in SharePoint sites.

https://docs.microsoft.com/en-us/graph/api/drive-list-following?view=graph-rest-1.0&tabs=http

eoverfield avatar May 21 '20 21:05 eoverfield

Thanks, @eoverfield, note that this same suggestion was already mentioned by @siljemda in the duplicated issue #5669, 16 days ago. In my experience, /me/drive/following does NOT return the same documents than _/api/social.following/my/followed(types=2). The followed documents we need are the same that appear under "Docs I'm following" in https://[YOUR TENANT]-my.sharepoint.com/personal/[USER_LOGON]/Social/FollowedContent.aspx

Rafaelki avatar May 22 '20 12:05 Rafaelki

Sorry to bother you @JeremyKelley ... it has been 15 days since your team started to investigate (more than 1 month since this bug was opened). Nothing yet to share?

Rafaelki avatar Jun 05 '20 16:06 Rafaelki

I'm not sure if this has been officially fixed or not, but my API calls started working correctly again.

sethstevenson avatar Jun 05 '20 16:06 sethstevenson

True. Both isfollowed and followed(types=2) are working for me as well. Thanks @sethstevenson.

Rafaelki avatar Jun 05 '20 16:06 Rafaelki