Can not upload file to SharePoint site

Chen, Nyon-ZL 25 Reputation points
2025-01-13T06:53:33.3266667+00:00

We are have a specific SharePoint site https://xxx.sharepoint.com/sites/XXX_SCHEME/ (the site name had masking) is using a java program with graph api. We confirm the site had been grant the write permission. It will show the error as below, may I know this issue is cause by which part? Thanks!

2025-01-10 13:59:49.086 ERROR 2623019 --- [           main] global                                   : CoreHttpProvider[send] - 220Graph service exception Error code: invalidRequest

2025-01-10 13:59:49.087 ERROR 2623019 --- [           main] global                                   : CoreHttpProvider[send] - 220GET https://graph.microsoft.com/v1.0/sites/xxx:sharepoint:com:/sites/``XXX_SCHEME``/

GET https://graph.microsoft.com/v1.0/sites/xxx:sharepoint:com:/sites/``XXX_SCHEME``/

SdkVersion : graph-java/v2.10.0 Authorization : [PII_REDACTED]

400 : Bad Request [...]

[Some information was truncated for brevity, enable debug logging for more details]         at com.microsoft.graph.http.GraphServiceException.createFromConnection(GraphServiceException.java:496)         at com.microsoft.graph.http.CoreHttpProvider.handleErrorResponse(CoreHttpProvider.java:503)         at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:423)         at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:220)         at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:200)         at com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:345)         at com.microsoft.graph.http.CustomRequest.get(CustomRequest.java:43)

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,899 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,230 questions
0 comments No comments
{count} vote

Accepted answer
  1. Saranya Madhu-MSFT 1,250 Reputation points Microsoft Vendor
    2025-01-13T07:43:39.0966667+00:00

    Hi Chen, Nyon-ZL,

    Thanks for reaching out to Microsoft!

    400 error occurs when the request can't be processed because it's malformed or incorrect.

    Graph API to upload files to SharePoint drive:

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

    If you want to upload large files, you can upload large files with an upload session, please try to use the following Graph API to create an upload session:

    POST /sites/{siteId}/drive/items/{itemId}/createUploadSession 

    Upload small files: Upload or replace the contents of a DriveItem (Note: This method only supports files up to 4MB in size.)

    Upload large files: Upload large files with an upload session

    Ensure that the Graph API is valid to upload files.

    Hope this helps.

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

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.