SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.24k stars 1k forks source link

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

Closed Hermitude closed 4 years ago

Hermitude commented 4 years ago

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

Category

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.

msft-github-bot commented 4 years ago

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

Jerry0527 commented 4 years ago
  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

Hermitude commented 4 years ago

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.

Kamalasekaran commented 4 years ago

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

siljemda commented 4 years ago

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.
sethstevenson commented 4 years ago

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
        })
WaltBC commented 4 years ago

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!

andrewconnell commented 4 years ago

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

akashpanjwani commented 4 years ago

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
Hermitude commented 4 years ago

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

WaltBC commented 4 years ago

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!

andrewconnell commented 4 years ago

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

akashpanjwani commented 4 years ago

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

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

JeremyKelley commented 4 years ago

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.

Rafaelki commented 4 years ago

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

eoverfield commented 4 years ago

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

Rafaelki commented 4 years ago

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 commented 4 years ago

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?

sethstevenson commented 4 years ago

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

Rafaelki commented 4 years ago

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

andrewconnell commented 4 years ago

@Hermitude can you confirm its working for you as you were the OP?

Hermitude commented 4 years ago

It's working for me too. Any idea what happened?

andrewconnell commented 4 years ago

¯_(ツ)_/¯ looks like someone rolled a fix out :)

Rafaelki commented 4 years ago

I think this issue should not be closed because Jeremy said that he or his team will come back with an update based on what they find. They should have the opportunity to explain.

andrewconnell commented 4 years ago

@Rafaelki They can, there's nothing blocking them from commenting on the closed issue... technically the issue is fixed though, so it makes sense to close it as it's no longer reproducible... that's why I asked the OP @Hermitude to confirm since he/she owns the issue.

msft-github-bot commented 4 years ago

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues