Error writing file to SharePoint with GraphAPI using createUpload Session

Michael Budney 1 Reputation point
2022-07-05T20:10:45.093+00:00

I'm trying to write a binary file from an Azure storage account to a SharePoint document library using Azure Data Factory. I'm using an Azure Python Function to get the bytes for the file and the size of the file in bytes. I'm able to to get the upload session, which causes the Items count in the library to actually increase each time but there are no files visible.

I've also tried in Postman by attaching a binary file locally and I get the same error message.

Create Upload Session (works)

 {  
        "url": "https://graph.microsoft.com/v1.0/drives/xxxxxxxxxxxxxxxxxxxxxxxxxxx/items/xxxxxxxxxxxxxxxxxxxxxxxxxxx/360140.pdf:/createUploadSession",  
        "method": "POST",  
        "headers": {  
            "Content-Type": "application/json",  
            "Authorization": "Bearer xxxx"  
        },  
        "body": "{\n\t'microsoft.graph.conflictBehavior': 'replace',\n\t'fileSize': '631024',\n\t'name': '360140.pdf'\n},'deferCommit': false"  
    }  

 

Writing file to SharePoint with the URL created from createUploadSession fails.

{  
    "url": "https://xxxxx.sharepoint.com/sites/Test/_api/v2.0/drives/xxxxx/items/xxxxx/uploadSession?guid='88b41b1c-5ed9-4c1d-8fac-ed9123079188'&overwrite=True&rename=False&dc=0&tempauth=eyJ0eX.....",  
    "method": "PUT",  
    "headers": {  
        "Authorization": "Bearer xxxx",  
        "Content-Length": "631024",  
        "Content-Type": "application/octet-stream"  
    },  
    "body": <the byte data>,  
    "disableCertValidation": true,  
    "httpRequestTimeout": "00:05:00"  
}  

Error Message

Error calling the endpoint 'https://xxxxx.sharepoint.com'. Response status code: 'NA - Unknown'. More details: Exception message: 'NA - Unknown [ClientSideException] An error occurred while sending the request.'.
Request didn't reach the server from the client. This could happen because of an underlying issue such as network connectivity, a DNS failure, a server certificate validation or a timeout.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,025 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,226 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,186 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,246 Reputation points
    2022-07-08T09:14:01.887+00:00

    Hi @Michael Budney ,

    We recommend you to open a ticket on this issue, more professional engineers will help you to determine if it is a bug. 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.


    0 comments No comments

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.