List_SharePoint_Sites() returns error 404
One of my users is experiencing an issue with this package when using the List_SharePoint_Sites() command. The command always returns the following error:
Using authorization_code flowWaiting for authentication in browser... Press Esc/Ctrl + C to abortAuthentication complete.Error in process_response(res, match.arg(http_status_handler), simplify) : Not Found (HTTP 404). Failed to complete operation. Message: Requested site could not be found.
Retrieving individual sites works as expected, and the user can retrieve their followed sites via Graph using the GET https://graph.microsoft.com/v1.0/me/followedSites endpoint via PowerShell and Graph Explorer.
Troubleshooting steps taken:
- Re-installed the package.
- Cleared the cached credentials via AzureAuth::clean_token_directory() and AzureGraph::delete_graph_login()
- Tried running List_SharePoint_Sites with explicit app id of AzureR/Microsoft365R default Enterprise Registration.
- Tried running List_SharePoint_Sites with explicit app id of a custom App Registration.
- Tested https://graph.microsoft.com/v1.0/me/followedSites Graph endpoint via Graph Explorer.
- Tested https://graph.microsoft.com/v1.0/me/followedSites Graph endpoint via PowerShell with the AzureR/Microsoft365R Enterprise Registration Application (Client) ID.
This is likely to be a problem with the server. Wait 24 hours and see if it persists.
This is likely to be a problem with the server. Wait 24 hours and see if it persists.
The issue has been happening since November 2024 and we have tried everything to troubleshoot it. Microsoft has also helped from their end in investigating any possible Graph or user identity issues with no success (everything is fine on those ends).
Did you create your own app ID? If so, can you show me the permissions?
Did you create your own app ID? If so, can you show me the permissions?
The error occurs the same way with the official AzureR/Microsoft365R Enterprise Application (d44a05d5-c6a5-4bbb-82d2-443123722380) and with a custom App Registration. Both applications have been given the required permissions listed in the app_registration.md guidance:
- User.Read
- Files.ReadWrite.All
- Group.ReadWrite.All
- Directory.Read.All
- Mail.Send
- Mail.ReadWrite
- Sites.Manage.All
- Sites.ReadWrite.All
- email, profile, openid, offline_access
The user is able to retrieve the list of sites they follow when using Graph over PowerShell. Could you confirm if List_SharePoint_Sites() uses the following MS Graph endpoint?
https://graph.microsoft.com/v1.0/me/followedSites
Yes, it uses the followedSites endpoint. This is the documentation:
https://learn.microsoft.com/en-us/graph/api/sites-list-followed?view=graph-rest-beta&tabs=http
@elipousson you probably know more about Sharepoint than me, have you had any problems with listing sites?
Yes, it uses the followedSites endpoint. This is the documentation:
https://learn.microsoft.com/en-us/graph/api/sites-list-followed?view=graph-rest-beta&tabs=http
@elipousson you probably know more about Sharepoint than me, have you had any problems with listing sites?
Does the package use the Beta endpoint or the v1.0?
It uses the beta endpoint. You can change to the 1.0 endpoint by running options(azure_graph_api_version="v1.0")
It uses the beta endpoint. You can change to the 1.0 endpoint by running
options(azure_graph_api_version="v1.0")
Thanks. We tried testing the List_SharePoint_Sites() with the V1.0 option but it still returns the same error. Any other ideas on how to troubleshoot it?
I suspect this is something peculiar to your install. It doesn't seem like anyone else is affected.
Does this happen to everyone, or just that particular user?
You can try running just the underlying AzureGraph code, without MS365R loaded:
library(AzureGraph)
gr <- get_graph_login(tenant=*, app=*, ...)
call_graph_endpoint(gr$token, "me/followedSites")
Huh, I tried using the AzureGraph code and I wasn't able to list the followed sites. I did not get the "Requested site could not be found" error — just an "Access denied" message. My permissions are locked down in some weird ways, though, e.g. I can't use get_business_onedrive(), so I expect this is just one of those things that isn't enabled for me.
@elipousson does the regular list_sharepoint_sites() work? The AzureGraph call may be incorrect, it's been some time since I looked at that package.
I suspect this is something peculiar to your install. It doesn't seem like anyone else is affected.
Does this happen to everyone, or just that particular user?
You can try running just the underlying AzureGraph code, without MS365R loaded:
library(AzureGraph) gr <- get_graph_login(tenant=*, app=*, ...) call_graph_endpoint(gr$token, "me/followedSites")
I confirmed with the user that they are able to retrieve the list of Followed Sites using the AzureGraph package directly with this snippet:
library(AzureGraph) graph <- get_graph_login() operation <- "me/followedSites" response <- call_graph_endpoint(graph$token, operation, http_verb = "GET") print(response)
The output is a list of all the SharePoint sites they follow containing site ID, Display Name, Description, and Web URL.
So something might be happening with the way the Microsoft365R package handles it?
That should be exactly the same code that Microsoft365R uses. Does anyone else in your org have this problem, or is it just this user?
That should be exactly the same code that Microsoft365R uses. Does anyone else in your org have this problem, or is it just this user?
It affects a couple of my users. Both tried re-installing RStudio and the whole package and its dependencies, but the issue is still the same.
Ok, but are there people for whom it works?
Yes, I have several users who can use the package just fine. The affected users experience the same issue when testing from the machine of one of the unaffected users, so it partly seems to be related to the individual user accounts (but again, not when using the AzureGraph library directly).
In that case I don't think I can help much; I'm not an AzureAD/MS Identity expert. What you can try is to register another app ID for the package, in case there's something wonky with the existing ID.
Oh, something else to try: delete the contents of the AzureAuth cache folder, usually in c:\users\___\AppData\Local\AzureR
Oh, something else to try: delete the contents of the AzureAuth cache folder, usually in c:\users___\AppData\Local\AzureR
My user doesn't see a cache folder in that directory, only the login token files. We already tried deleting these as part of the initial troubleshooting, but it only seems to clear the cached credential and prompt for a new login on the next run of the package, with the issue persisting.
Is there any other option for troubleshooting? As a recap, the user can successfully send GET requests to the me/followedsites endpoint via Graph Explorer, Graph over PowerShell, and AzureGraph in RStudio. They receive the following error when trying to do so via AzureR: "Not Found (HTTP 404). Failed to complete operation. Message: Requested site could not be found." The user can query individual sites directly and we have tested using a custom Entra App registration as well with the same results, so an authentication issue is unlikely.
How is the error message sourced? Is it parsed directly from the API request response?
Any updates on this? Has anyone else raised the same issue?
I think it's just you.
You can try running AzureAuth::clean_token_directory() to make sure there's no stale tokens lying around (this is what the instruction to delete the cache folder does).
I did see something similar in an environment where the app ID wasn't authorised; running list_sharepoint_sites() resulted in a 404, while running the underlying AzureGraph function resulted in a different error. So it could be that different paths give different results, although this shouldn't happen.
Otherwise, you can create a new app registration, give it all the necessary permissions and login with that.
I'm having the same issue.
> list_sharepoint_sites()
Using authorization_code flow
Creating Microsoft Graph login for default tenant
Using authorization_code flow
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Error in process_response(res, match.arg(http_status_handler), simplify) :
Not Found (HTTP 404). Failed to complete operation. Message:
Requested site could not be found.
Also having the same issue. I have previously been able to execute this operation fine in the past, and I can still successfully list sites using the AzureGraph functions.
Confirming that the issue is still occurring on our end as well. The app registration has been authorised and works for some of our users. The affected users have the same issue with a custom app registration.
This issue began occurring for our team last week. The list_sharepoint_sites() returns a 404 error. The list_teams() works just fine. Going the AzureGraph way to call_graph_endpoint(..., "me/followedSites") also works fine. Unclear when this issue began happening for us though, but it was certainly functional in February.
I had the same problem In my case it was because I was following 'sites' that were for 'channels' that have been deleted. The solution, for me, was to go to MS 365 - pick SharePoint, and scroll down to 'following' - unstar the ones that no longer exist.
I had the same problem In my case it was because I was following 'sites' that were for 'channels' that have been deleted. The solution, for me, was to go to MS 365 - pick SharePoint, and scroll down to 'following' - unstar the ones that no longer exist.
Tested this with my users and confirmed it to work. It looks like the package has some trouble handling the list of Followed Sites if it includes sites that the user no longer has access to (e.g. site has been deleted or user has been removed from site).