The site in the encoded share URI is invalid

喜夏-厌秋 提交于 2020-07-22 22:03:00

问题


I've tried to use Microsoft Graph to pull some files from a shared link. However, when I try to do that using the Microsoft Graph Explorer, it returns:

"error": {
   "code": "invalidRequest",
   "message": "The site in the encoded share URI is invalid.",
   "innerError": {
       "request-id": "e07b0df4-88e0-49fd-97e4-eccaaf887d6e",
       "date": "2019-11-29T19:05:52"
    }
}

The encoding code is this(same as on the docs):

string base64Value =
  Convert
  .ToBase64String(UTF8
        .GetBytes("https://1drv.ms/f/s!An8UzxYP03zbg5lyUW0nVFclockIaw"));

string encodedUrl = "u!" + 
   base64Value.TrimEnd('=')
  .Replace('/', '_')
  .Replace('+', '-');

The link is in the code and goes to an empty shared folder (for testing purposes).


回答1:


i had the same problem, turned out i wasn't logged into graph under my account

derp.




回答2:


UPDATE

Soo, a couple of months have passed and I have managed to fix my problem:

How did I do it?

TLDR: The share URI isn't extracted as MS tells you (for whatever reason)

Let's take my example folder:

https://1drv.ms/f/s!An8UzxYP03zbg5lyUW0nVFclockIaw

In this case, the URI is everything after(including)the "s" part, so in my case it's s!An8UzxYP03zbg5lyUW0nVFclockIaw

CODE

    private static string GetIDFromLink(string website)
    {
        return "s!" + website.TrimStart("https://1drv.ms/f/".ToCharArray());
    }

Don't forget that you MUST be logged in to MSGraph and have the proper permission to access files Also, if you're using the "Application Daemon" method(aka, no user sign-in) you must have a SharePoint 365 subscription active(at least from what I've observed, I would like to be wrong on that)



来源:https://stackoverflow.com/questions/59109993/the-site-in-the-encoded-share-uri-is-invalid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!