5
votes

This question has been asked before with not much success.

The documentation is totally unclear too. It implies that to create a new list item one would do the following. But doesn't give a specific example on attachments.

The listitem documentation has a sneaky caveat right at the end which says that files/document libraries are treated as driveitems:

For document libraries, the driveItem relationship exposes the listItem as a driveItem

Right, so does that mean that all files are then related to driveitems? It seems closer as the driveitem docs talk about the following example (indicating site-related content which is SharePoint)

PUT /sites/{site-id}/drive/items/{parent-id}:/{filename}:/content

But the above route doesn't specify a list-id either an item-id. So how does that fit in?

Which route do we hit to upload attachments on a list item? I have tried numerous requests:

PUT - https://graph.microsoft.com/v1.0/sites/root/lists/2696fba7-2cc5-482f-805e-a3dbf853e5e9/items/1/content

PUT - https://graph.microsoft.com/v1.0/sites/root/drive/items/1/createUploadSession (not list id though?)

1
Looks like a duplicate of this one: stackoverflow.com/questions/41285403/…Tracy

1 Answers

0
votes

To upload an small item (<4MB) into a Sharepoint Online document library or list which is not the default library, you can youse the following url syntax:

https://graph.microsoft.com/v1.0/sites/{SITE-ID}/drives/{DRIVE-ID}/root:/{FILENAME}:/content

  • {SITE-ID}: the id of sp site
  • {DRIVE-ID}: the id of drive (document library or list)
  • {FILENAME}: the name of the fie to upload

The "/root:" after the drive id is the important point.