1

I am trying to add a new document using the Microsoft graph api inside a certain document library.

Image

I would like to add the document inside this document library.

I tried using this endpoint https://graph.microsoft.com/v1.0/sites/*****-****-451d-bc8f0642868b326/drive/root:/Signing/Izjava.pdf:/content but this only adds the document to the drive root and creates a folder called Signing with a file inside.

1 Answer 1

2

Please note that, you missed including DRIVE_ID in the query that refers to ID of document library.

I tried to reproduce the same in my environment by running the same query as below:

PUT https://graph.microsoft.com/v1.0/sites/{SITE_ID}/drive/root:/Signing/Izjava.pdf:/content

Response:

enter image description here

As I missed including DRIVE_ID in the query, it added the document to the drive root by creating a folder called Signing with a file named Izjava.pdf inside it like below:

enter image description here

To add a new document inside a certain document library, you need to include DRIVE_ID in the query like below:

PUT https://graph.microsoft.com/v1.0/sites/{SITE_ID}/drives/{DRIVE_ID}/root:/{DOC_NAME}:/content 

Response:

enter image description here

The document named Izjava.pdf created and uploaded to document library Signing successfully like below:

enter image description here

To get the DRIVE_ID of your document library, you can query like below:

GET https://graph.microsoft.com/v1.0/sites/{SITE_ID}/drives

Response:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.