SharePoint api uploads file from postman with 201 response but not visible in Library

Arora, Manan 25 Reputation points
2024-12-11T09:52:45.1633333+00:00

Hi,

I am trying to upload a file using api(curl mentioned below) to a sharepoint. file name is "Test1" and it is an txt file, once uploaded it does not show on the library.

I tried to upload the exact file again or different csv file as well, still it is not visible though I can see the sharepoint folder item counts increases but file is hidden.

curl --location --request PUT 'https://graph.microsoft.com/v1.0/drives/{{DriveID}}/items/root:/folder_path/Test1.txt:/content' \ --header 'Authorization: Bearer {{access_token}}' \ --header 'Content-Type: text/plain' \ --data-binary '@/C:/Users/OneDrive/Downloads/IDEA.docx'

I am a SharePoint admin so I can see everything on the site but there is nothing there.

Can anyone help to possibly find out what is going on as this has never happened before?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,800 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,200 questions
0 comments No comments
{count} votes

Accepted answer
  1. Emily Du-MSFT 48,926 Reputation points Microsoft Vendor
    2024-12-17T11:02:08.07+00:00

    I'm glad to hear you found the answer for the issue, if you have any other 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.". So, I would make a brief summary of this thread:

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

    [SharePoint Api uploads file from postman with 201 response but not visible in Library]

    Issue Symptom:

    OP is a SharePoint admin can see everything on the site.

    When trying to upload a file using Api to SharePoint, file name is "Test1" and it is an txt file, once uploaded it does not show on the library.

    OP tried to upload the exact file again or different csv file, OP can see the SharePoint folder item counts increases but file is hidden.

    curl --location --request PUT 'https://graph.microsoft.com/v1.0/drives/{{DriveID}}/items/root:/folder_path/Test1.txt:/content' \ --header 'Authorization: Bearer {{access_token}}' \ --header 'Content-Type: text/plain' \ --data-binary '@/C:/Users/OneDrive/Downloads/IDEA.docx'
    

    Current status:

    OP got the solution from the answers posted here: https://learn.microsoft.com/en-us/answers/questions/1350545/i-cannot-view-see-my-files-which-i-have-uploaded-t


    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.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Arora, Manan 25 Reputation points
    2024-12-16T07:45:13.37+00:00
    1 person found this answer helpful.

  2. Saranya Madhu-MSFT 1,080 Reputation points Microsoft Vendor
    2024-12-11T11:10:51.15+00:00

    Hi Arora, Manan,

    Thanks for reaching out to Microsoft!

    I used the following API endpoint to upload the file:

    PUT https://graph.microsoft.com/v1.0/drives/{drive-id}/items/root:/{filename}:/content

    Content-Type: text/plain

    The response was successful, indicating that the file was uploaded correctly.

    Can you please verify below:

    After uploading, please navigate to the "webUrl(URL that displays the resource in the browser)" property in the response. This property provides the direct URL to the uploaded file.

    Check whether you are able to access the file using this URL.

    Reference document : https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http

    Hope this helps.

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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.