1

The newly added DriveItem object returns the listItem field as null, which means that the relationship between DriveItem and ListItem offered by Graph Api cannot be used.

I created new DriveItem:

var driveItemResult= await CreateGraphClient().Groups[_options.GroupId].Sites[_options.SiteId]
                        .Drives[_driveOptions.DriveId]
                        .Root
                        .Children
                        .Request()
                        .AddAsync(driveItem).ConfigureAwait(false);

Now I would like to update custom columns in it. I know this is possible if you get driveItem as listItem. So I would like to do this:

var listItem= await CreateGraphClient().Groups[_options.GroupId].Sites[_options.SiteId]
                        .Lists[_listOptions.ListTitle]
                        .Items[driveItemResultId]
                        .Request()
                        .AddAsync(driveItem).ConfigureAwait(false);

But driveItemResult.Id returns Guid. I need Id as number to take Item from list. And driveItem has property listItem. So I thought I can get correct id if I take driveItem.ListItem.Id but driveItem.ListItem is always null.

Do you know what could caused this behavior or how to get correct id?

  • Can you please provide more details of your requirements? – Litt Spector Dec 9 '19 at 5:24
  • Please add what you are trying to do..a code snippet will help.. – Siddharth Vaghasia Dec 9 '19 at 5:46
  • I added part with code. I will be grateful for help. – Iwoo Dec 9 '19 at 12:57
0

You can get the list item through below code:

CreateGraphClient().Groups[_options.GroupId].Sites[_options.SiteId]
                    .Drives[_driveOptions.DriveId]
                    .Items[driveitemid]
                    .ListItem
                    .Request().GetAsync()

Listitem is a expand property of driveitem, by default it has not been initialized. so we need to request it again.

BR

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.