In this article, we’ll show how to pull the file from the FTP location and upload to the SharePoint repository.

To complete this article we should have followings:

  • Sharepoint REST connection: Refer the article to create Sharepoint connection with REST API
  • FTP connection: Refer the article to create the FTP connection
Below is the Sharepoint REST API which is used to upload the document in Sharepoint repository.

URL:

https://online.sharepoint.com/sites/<site_name>/ _api/web/GetFolderByServerRelativeUrl(‘<relative_patjh_of_folder>’)/Files/add(url='<doc_name>’,overwrite=true)
For example:

Headers:

Authorization: Bearer <access_token>
Accept: application/json; odata=verbose
Request Payload:
Upload file as binary in body
Use the above API in Oracle Integration cloud to upload the document.
  • Create a scheduled integration
  • Drop the FTP adapter and enter the name of the endpoint(ListFiles)
  • Configure properties as below and click on the Next button
    • Select Operation: List File
    • Input Directory: Enter the directory from which files to be listed
    • File Name Pattern: *
  • Complete the wizard
  • Drop For-Each activity just below the FTP adapter and configure properties as below
    • Name: LoopOverTheFiles
    • Repeating Element: Drop the repeated element of ListFile Response
    • Current Element Name: CurrentFile
  • Drop the FTP adapter(under For each) from where the file needs to read, enter the name of endpoint(ReadFiles) and click the Next button
  • Configure properties as below and click on the Next button
    • Select Operation: Read File
    • Input Directory: Enter the directory from where the files to be read
    • File Name Pattern: abc.txt
  • Select No radio button from Do you want to define the schema for this endpoint? and click the Next button

  • Complete the wizard
  • Edit the ReadFiles mapper and do the mapping as below:
    • CurrentFile->File->directory ——>  SyncReadFile->FileReadRequest->directory
    • CurrentFile->File->filename  ——>  SyncReadFile->FileReadRequest->filename
  • Drop the Sharepoint REST connection, configure below properties and click the Next button
    • What do you want to call your endpoint: UploadDoc
    • What is the endpoint’s relative resource URI?
/sites/{site}/_api/web/GetFolderByServerRelativeUrl(‘{Folder Name}’)/Files/add(url='{documentname}’,overwrite=true)
    • What action does this endpoint perform: POST
    • Check the checkbox Add and review parameters for this endpoint
    • Check the checkbox Configure a request payload for this endpoint
    • Check the checkbox Configure this endpoint to receive the response
  • Click the Next button
  • Select Raw radio button from Select the request payload format section and click the Next button
  • Select JSON Sample and then click the <<< inline >>> link, then enter below sample json
{
    “d”: {
        “__metadata”: {
            “id”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)”,
            “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)”,
            “type”: “SP.File”
        },
        “Author”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/Author”
            }
        },
        “CheckedOutByUser”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/CheckedOutByUser”
            }
        },
        “EffectiveInformationRightsManagementSettings”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/EffectiveInformationRightsManagementSettings”
            }
        },
        “InformationRightsManagementSettings”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/InformationRightsManagementSettings”
            }
        },
        “ListItemAllFields”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/ListItemAllFields”
            }
        },
        “LockedByUser”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/LockedByUser”
            }
        },
        “ModifiedBy”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/ModifiedBy”
            }
        },
        “Properties”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/Properties”
            }
        },
        “VersionEvents”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/VersionEvents”
            }
        },
        “Versions”: {
            “__deferred”: {
                “uri”: “https://online.sharepoint.com/sites/devsite/_api/Web/GetFileByServerRelativePath(decodedurl=’/sites/devsite/ParentFolder/TestFolder/doc1.pdf’)/Versions”
            }
        },
        “CheckInComment”: “”,
        “CheckOutType”: 2,
        “ContentTag”: “{ssss121212-9294-4332-9D09-BBsdds2232323},7,2”,
        “CustomizedPageStatus”: 0,
        “ETag”: “”{ ssss121212-9294-4332-9D09-BBsdds2232323},7″”,
        “Exists”: true,
        “IrmEnabled”: false,
        “Length”: “1564522”,
        “Level”: 1,
        “LinkingUri”: null,
        “LinkingUrl”: “”,
        “MajorVersion”: 7,
        “MinorVersion”: 0,
        “Name”: “doc1.pdf”,
        “ServerRelativeUrl”: “/sites/devsite/ParentFolder/TestFolder/doc1.pdf”,
        “TimeCreated”: “2019-05-16T10:03:27Z”,
        “TimeLastModified”: “2019-05-16T10:03:27Z”,
        “Title”: “Test tilte Updated”,
        “UIVersion”: 3584,
        “UIVersionLabel”: “7.0”,
        “UniqueId”: “2211de2-9294-1111-2222-ff45b5bc2e0f”
    }
}
  •  Select Other Media type and enter application/json; odata=verbose. Click on the Next button
  • Edit the UploadDoc mapper and do the mapping as below:
    • ReadFiles….->FileReference —– > streamReference
    • ReadFiles….->filename —–> TemplateParameters -> documentname
    • Hard code the sitename as “devsite” 
    • Hard code the foldername as “Shared%20Documents/TestFolder

The integration is completed now. Activate the integration.

  • Put some files on the SFTP location and Submit the integration
  • See all the files should be uploaded into the Sharepoint repository.