question

JC90-8327 avatar image
0 Votes"
JC90-8327 asked saldana-msft edited

Upload secure pdf to SharePoint folder using GraphAPI

We have a pdf file that fails to upload to SharePoint via GraphAPI. No "id" is present/created in the json response causing it to not upload. I think it is because the pdf is secure and locked down. Here is a screenshot of the security on it. Is this what is causing the issue?194032-capture.png




Thank you.

sharepoint-devmicrosoft-graph-filesmicrosoft-graph-general
capture.png (36.0 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JC90-8327,
I am currently doing some research on this issue, will let you know as soon as possible.

0 Votes 0 ·
TongZhangMSFT-7548 avatar image
1 Vote"
TongZhangMSFT-7548 answered

Hi @JC90-8327,
I'm glad to hear you solve the problem ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.

By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:


[Upload secure pdf to SharePoint folder using GraphAPI]

Issue Symptom:
We have a pdf file that fails to upload to SharePoint via GraphAPI. No "id" is present/created in the json response causing it to not upload. I think it is because the pdf is secure and locked down.

Current status:
There is some code that was limiting the size of the file to 4mb. We have increased it and it is working now.


You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SrinivasaRaoDarna-MSFT avatar image
0 Votes"
SrinivasaRaoDarna-MSFT answered

Hi @JC90-8327,

I tried to replicate the same in my test environment, and I was able to upload password protected PDFs and access the uploaded files successfully using small file upload and large file upload API's.

  • Can you share the endpoint used and any possible screenshot of the response

  • Are you able to successfully upload the same file directly to SPO library

Reference documents:
driveitem-upload-content
driveitem-createuploadsession

Hope this helps.

If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TongZhangMSFT-7548 avatar image
0 Votes"
TongZhangMSFT-7548 answered

Hi @JC90-8327,

According to my research and testing, I successfully uploaded the pdf to SharePoint using Graph API, the test code is as follows, you can refer to :

 PUT  https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/root:/upload.pdf:/content

 Headers:
 Content-Type: application/pdf

Test results:
194126-image.png


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.





image.png (1.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JC90-8327 avatar image
0 Votes"
JC90-8327 answered

Thank you for the help and quick responses. The Graph api is working as intended. We had some code that was limiting the size of the file to 4mb. We have increased it and it is working now.
194443-capture.png



capture.png (18.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.