Sharepoint Module
Introduction
The Sharepoint module enables app developers to access information about lists, folders and files stored within a Microsoft Sharepoint instance. It covers basic information about found items and will provide any additional information in a dynamic Map called additionalAttributes. If items contain attachments, they will be listed as an Array of Byte-Strings in the attribute attachmentBytes.
Configuration
Field name |
Description |
Example |
Domain |
Name of the domain to be used to access the Sharepoint insctance |
mycompany.sharepoint.com/path |
Backend
Apiomat users that will have to access Sharepoint must use an e-mail address and password that correspond to a Sharepoint user. In order to access the api, the api-key of the backend needs to be provided. Api-docs provides a convenient way to test the functionality of the Sharepoint connector.
Therefore, there are no global log-in credentials to be set in the Sharepoint module.
Use
Getting information about lists is done using the SharepointList meta model. Simply call the usual methods to get either one object or all.
List<SharepointList> listOfLists =
SharepointList.getSharepointLists(
"Shared documents"
);
for
( SharepointList sharepointList : listOfLists )
{
System.out.println( sharepointList.getTitle( ) );
}
The meta models called SharepointFile and SharepointFolder provide information about files and folders located in a particular folder. Therefore, you need to specify which folder to use by passing the folder path in the query. The query should not contain any other information.
private
static
void
printFolders( String parentFolderPath )
throws
ApiomatRequestException
{
List<SharepointFolder> folderList =
SharepointFolder.getSharepointFolders( parentFolderPath );
for
( SharepointFolder sharepointFolder : folderList )
{
String subFolderPath = sharepointFolder.getForeignId( );
System.out.println( subFolderPath );
printFiles( subFolderPath );
printFolders( subFolderPath );
}
}
private
static
void
printFiles( String parentFolderPath )
throws
ApiomatRequestException
{
List<SharepointFile> files = SharepointFile.getSharepointFiles( parentFolderPath );
for
( SharepointFile sharepointFile : files )
{
System.out.println( sharepointFile.getHref( ) );
}
}
The meta model SharepointFolderContent can be used additionally to get both sub-folders and files that are located inside a certain folder by specifying the folder path in the query. This will return an object which holds lists of references to objects of SharepointFile and SharepointFolder.
REST-Interface
Load a complete List
GET <baseURL>/yambas/rest/apps/<AppName>/models/Sharepoint/SharepointList
Query: key=="value" example: title=="Todos"
possible keys: title / foreignId / description / entityTypeName / imageURL / parentWebUrl / templateFeatureId
Load a list item
GET <baseURL>/yambas/rest/apps/<AppName>/models/Sharepoint/SharepointListItem/
dataModelId <foreignId-of-parent>__<itemId> example: 410c6c68-25a1-42a0-b542-dc6cd83784b9__2
explanation for the example:
410c... is the foreignId of Todos
__ is a double _underline that separates the ids
2 is the second item on Todos (caution: list items always start at 1)
(default) if no list item id is provided (..84b9 ) __1 is assumed
Update a list item
PUT <baseURL>/yambas/rest/apps/<AppName>/models/Sharepoint/SharepointListItem/
dataModelId: <foreignId>
Behavior: If an item is saved the server will respond with Status 200 and the item will have been updated.
Important: @type and foreignId need to be provided
{
"@type"
:
"Sharepoint$SharepointList"
,
"foreignId"
:
"506e9fc8-8669-42a5-a69b-1723783f9882"
...
}
Reading ListItems
{
"@type"
:
"Sharepoint$SharepointListItem"
,
"createdAt"
:
1474964472340
,
"lastModifiedAt"
:
1474964472340
,
"id"
:
null
,
"applicationName"
:
"TestSharepoint"
,
"moduleName"
:
"Sharepoint"
,
"allowedRolesRead"
: [],
"allowedRolesWrite"
: [],
"allowedRolesGrant"
: [],
"restrictResourceAccess"
:
false
,
"foreignId"
:
"506e9fc8-8669-42a5-a69b-1723783f9882__1"
,
"referencedHrefs"
: {},
"additionalAttributes"
: {
"ParentID"
:
""
,
...
},
"assignedTo"
:
"Mr. Mister"
,
"attachmentBytes"
: [
"�PNG\r\n\u001a...
],
"dueDate"
:
"07.10.2016"
,
"guid"
:
"e47d9d03-14bd-433c-9152-7bdfb1d92868"
,
"listId"
:
"506e9fc8-8669-42a5-a69b-1723783f9882"
,
"order"
:
1
,
"percentComplete"
:
"20 %"
,
"title"
:
"Testen der Aufgaben"
,
"href"
:
"<baseURL>/yambas/rest/apps/<AppName>/models/Sharepoint/SharepointListItem/506e9fc8-8669-42a5-a69b-1723783f9882__1"
}
"foreignId" is consists of two ids where the part on the left before "__" is the foreignId of the parent List and the number on the right resembles the index of the Sharepoint item. The attributes from "@type" to "additionalAttributes" will be provided by ApiOmat, while "assignedTo" to "title" will be provided by Sharepoint and will only be mapped by ApiOmat. Additional information that was provided by Sharepoint will be found in "additionalAttributes". The attribute "attachmentBytes" contains an Array of Byte-Strings resembling the attached binary files.
Limitations
-
At the moment, it is not possible to actually download any resources that are located inside Sharepoint.
-
It is not possible to upload new files or edit properties, either.
-
It is not possible to delete or create new items
-
Passing a path as the content of the query is not possible in the new dashboard.