I'm using the code sample below but I get an invalidRequest error.
The drive and driveItem Ids are correct.
I try the same using the Microsoft Graph Explorer and it informs that I need to consent to missing permissions. It does not indicate which permissions.
The application has Files.ReadWrite.All, Files.Read.All, Sites.ReadWrite.All, Sites.Read.All which Microsoft's documentation suggest is enough.
A web article suggested that the application also needs Sites.Manage.All and Sites.FullControl.All. However, these did not resolve the issue. An invalidRequest is returned:
2022-02-02T17:50:13 Exception: Code: invalidRequest
Message: Invalid request
Inner error:
AdditionalData:
date: 2022-02-02T17:50:03
request-id: 8e6*****-****-****-****-******382c2c
client-request-id: 8e6*****-****-****-****-******382c2c
Anyone know what permissions are needed or need to be consented?
// Create a shared link
var type = "edit"; // edit or view or embed
var scope = "organization"; // Also anonymous or organization
try
{
var result = await graphServiceClient.Drives[documentsDrive.Id].Items[pcScheduleAssessmentsFolderForStudent.Id]
.CreateLink(type, scope, null, null, null, null)
.Request()
.PostAsync();
}
catch (Exception ex)
{
string errMsg = DateTime.Now.ToString("s") + " Exception: " + ex.Message;
if(ex.InnerException != null)
{
errMsg += " InnerException: " + ex.InnerException.Message;
}
logger.LogError(errMsg);
return;
}
