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).
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:
In this case, the URI is everything after(including)the "s" part, so in my case it's
s!An8UzxYP03zbg5lyUW0nVFclockIawCODE
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)