Web Activity to call Sharepoint REST API copyTo Method

Leau Bee Lin 86 Reputation points

1) Web Activity "GetBearerToken" to get authorization (bearer) token is working
2) After the above, create another Web Activity "CopyTo" to copy file in SharePoint document library is as below.

https://{Site Url}/_api/web/GetFileByServerRelativeUrl('/sites/TestSite/Shared%20Documents/test.xlsx')/copyTo(strNewUrl='/sites/TestSite/Shared%20Documents/testCopy.xlsx',bOverWrite=true)

Method = POST

Authorization=@{concat('Bearer ', activity('GetBearerToken').output.access_token)}

It is giving error : {"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Not well formatted JSON stream."}}}

Please advise what is missing.

3) Is there a limitation on the length of REST API URL? 299?

Thanks in advance.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
6,345 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.
1,701 questions
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 14,556 Reputation points Microsoft Employee

    Hi @Leau Bee Lin ,
    Per my test, I can get Access Token without grant permission to the client id. So I will agree with ShaikMaheer's opinion. Please check if you have grant permission to the client id. You can refer to following steps:
    Go to the appinv.aspx page by the url


    Fill the client id and click look up and App's Permission Request XML like the pic


    <AppPermissionRequests AllowAppOnlyPolicy="true">  
    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />  

    You can choose permission level by following link

    Click create and then trust it
    The document for reference

    Finally the maximum length of the Request URI for requests to our REST API endpoints is 4096 characters. If the request URI exceeds this length, you should see the following error message in the response:

    URI length exceeds the configured limit of 4096 characters  

    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.

1 additional answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 28,261 Reputation points Microsoft Employee

    Hi @Leau Bee Lin ,

    From the error messages it seems its related to access issue.

    May be the authentication which you are using is not having access on API. Could you please try to use your token via postman or other third party API request services and see is it working there?