We’ve received a couple of questions on how to upload to SharePoint, using Linx, and SharePoint does provide a complete REST API. Where the difficulty comes in is, one first need to set SharePoint up to allow access to an App like Linx. A good step-by-step guide is this one: http://www.ktskumar.com/2017/01/access-sharepoint-online-using-postman/
An administrator of the SharePoint site needs to register an app on the URL: https://sitename.sharepoint.com/_layouts/15/appregnew.aspx
Save the details, including the Client Id, and Client Secret
The Administrator then needs to go and grant permission to the Add-In at:
The permission XML needs to give the correct access. As a catch-all, I’ve used the following, but remember to set it correctly according to your requirements:
<AppPermissionRequests> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl"/> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="Read"/> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="Write"/> </AppPermissionRequests>
The next step is to get the Resource and Tennant IDs. I’ve used SOAPUI to extract this, but you can just follow the guide.
Once you’ve retrieved the Client ID, Client Secret, Resource and Tennant IDs, you can start using Linx to access the SharePoint Site.
Here is an example: SharePointTestGen.lsoz (16.2 KB)
In this solution (Set your settings):
- The first process (S1_GetSecToken) is used to get the security token and save it to a file. The reason for this is, the security token for this app on this site is only valid for a certain amount of time, thus you need the option to regularly get a new token.
- S2_GetTitle calls the SharePoint site to obtain its title
- S3_ListAll gets a list of all the objects on the root of the site
- S4_ListFolder lists the folders in the Shared Documents path of the site
- S5_ListFilesInFolder list the files in a specific path (Folder)
- S6_Uploads a Text file and calls it “Linx5.txt” on the SharePoint site
Each of these processes basically follows the same method:
- Get the security token
- Use the security token as an Authorization header with the word "Bearer " in front
- Uses the _api/web URL required
Some interesting reads: