Copy File from SharePoint not working

Etienne Viljoen 126 Reputation points
2020-09-28T04:21:48.037+00:00

Hi @KranthiPakala-MSFT ,

I am trying this method (https://learn.microsoft.com/en-us/azure/data-factory/connector-sharepoint-online-list#copy-file-from-sharepoint-online) but I get this error:

{
"errorCode": "2200",
"message": "Failure happened on 'Sink' side. ErrorCode=HttpFileFailedToRead,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Failed to read data from http server. Check the error from http server:The remote server returned an error: (403) Forbidden.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Net.WebException,Message=The remote server returned an error: (403) Forbidden.,Source=System,'",
"failureType": "UserError",
"target": "Copy Files_copy1",
"details": []
}

I have set up the prerequisites and configured the pipeline as described. The GetBearerToken succeeds and passes a token to the Copy Data activity. Any ideas what might be the issue.

(I have created another Activity using the SharePoint Online List and the same credentials I am trying to use to copy the files, to download a list of files and this works no problem)

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,508 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,591 questions
0 comments No comments
{count} vote

Accepted answer
  1. Etienne Viljoen 126 Reputation points
    2020-09-28T06:42:53.367+00:00

    I found this article http://www.ktskumar.com/2017/01/access-sharepoint-online-using-postman/ which helped me work through it step by step.

    This helped me to realize that I had given the app permission on a specific site collection (https://tenantname.sharepoint.com/teams/teamname) but when I tried to call the API, I sent the request to the top level (https://tenantname.sharepoint.com/_api/web/GetFileByServerRelativeUrl('[relative-path-to-file]')/$value) instead of the specific site I was working on (https://tenantname.sharepoint.com/teams/teamname/_api/web/GetFileByServerRelativeUrl('[relative-path-to-file]')/$value)

    Once this was corrected the problem was solved

    4 people found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. ranjit kurian 31 Reputation points
    2020-11-07T10:21:36.867+00:00

    Hi,

    Could you please help me to know how to get the Teams/Team Name details from sharepoint, even i am facing the same Sink error

    This is how my sharepoint path looks for me : https://{site url}/My%20Folder%20Name

    Tried with below two links and it didnt work:

    https://{site url}/_api/web/GetFileByServerRelativeUrl('/My Folder Name/My File Name.csv)/$value

    https://{site url}/_api/web/GetFolderByServerRelativeUrl('/My Folder Name')/Files('My File Name.csv')/$value

    Amened as per your above solution, but not sure how to get teams/teamname details.

    https://{site url}/teams/teamname/_api/web/GetFolderByServerRelativeUrl(''/My Folder Name')/Files('My File Name.csv')/$value

    Please advise...


  2. Taariq Toffar 1 Reputation point
    2021-03-25T12:22:21.357+00:00

    Hi,

    Could you assist I'm getting the below error when trying to copy a excel file from SharePoint to Azure Blob:

    Failure happened on 'Sink' side. ErrorCode=HttpFileFailedToRead,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Failed to read data from http server. Check the error from http server:The remote server returned an error: (400) Bad Request.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Net.WebException,Message=The remote server returned an error: (400) Bad Request.,Source=System,'

    81602-image.png

    The registered app has full control on all sites on SharePoint:

    81545-image.png


  3. anvesh Kumar 1 Reputation point
    2021-04-02T12:13:02.073+00:00

    Copy File from SharePoint not working.

    Hi,

    I am trying this method (https://learn.microsoft.com/en-us/azure/data-factory/connector-sharepoint-online-list#copy-file-from-sharepoint-online) but I get this error:

    Failed to import source schema. Failed to read data from http server.
    Check the error from http server:The remote server returned an error: (403) Forbidden.
    The remote server returned an error: (403) Forbidden.

    I have set up the prerequisites and configured the pipeline as described. The GetBearerToken succeeds and passes a token to the Copy Data activity.

    • Created a linked service to connect to SharePoint file path, connection was successful.
    • Created a web activity and connected with copy activity taking http as source(csv file),
    • when I try to import the schema from share point csv file it gives me below error.

    Admin has registered app in sharepoint at site level but when he tries to give the permission at subsite level it gives internal service error.

    We gave permission at site level in share point for eg( https://contoso.sharepoint.com) , when we try to give the permission at subsite level where the file resides it gives me internal server error

    Appreciate your help on this.

    Thanks