This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with lists and list items


Overview

The following operations allow you to carry out sharepoint operations. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to carry out file operations, see Sample configuration.

 

OperationDescription

createList

Create a List.

retriveLists

Retrieves all the Lists in the site

getListById

Retrieves a List by List GUID.
getListByTitleRetrieves a List by List title.
deleteListDelete a list.
retriveListItemsRetrieves all the Lists items in the list.
createListItemCreate a list item.
updateListUpdate a List.
getItemByIdRetrieves List item with specified ID.
deleteListItemDelete a List Item.
updateListItemsUpdate a List Item.

createCustomListItem

Creates dynamic List Item.

Operation details

This section provides details on each of the operations.

Create a list

This method allows you to Create a List.

createList
<sharepoint.createList>
    <type>{$ctx:type}</type>
    <allowContentTypes>{$ctx:allowContentTypes}</allowContentTypes>
    <baseTemplate>{$ctx:baseTemplate}</baseTemplate>
    <contentTypesEnabled>{$ctx:contentTypesEnabled}</contentTypesEnabled>
    <description>{$ctx:description}</description>
    <title>{$ctx:title}</title>
</sharepoint.createList>
Properties
  • type :Type when constructing the metadata variable.

  • allowContentTypes:  Boolean value, that specifies whether the list supports content types.

  • baseTemplates: Specifies list definition type on which the list is based.

  • contentTypesEnabledBoolean value, that specifies whether content types are enabled for the list.
  • descriptionDescription of the list.
  • title:  The title for the list. Its length must be less than or equal 255 characters.
Sample request

Following is a sample REST request that can be handled by the createList operation.

createList
{
  "apiUrl":"https://xxx.sharepoint.com",
  "type":"SP.List",
  "allowContentTypes": "true",
  "baseTemplate": "100",
  "contentTypesEnabled": "true", 
  "description": "My list description",
  "title":"BillInfoList",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Retrieve lists

This method allows you to Retrieves all the Lists in the site.

retriveLists
<sharepoint.retriveLists/>
Sample request

Following is a sample REST request that can be handled by the retriveList operation.

retriveLists
{
  "apiUrl":"https://xxx.sharepoint.com",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Get List By ID

This method allows you to retrieves a List by List GUID.

getListById
<sharepoint.getListById>
    <guId>{$ctx:guId}</guId>
</sharepoint.getListById>
Properties
  • guIdThe GUID of the list to return list.

Sample request

Following is a sample REST request that can be handled by the getListById operation.

getListById
{ 
  "apiUrl":"https://xxx.sharepoint.com",
  "guId":"14cf6f8b-5db4-4fb7-af20-07e058b3bcfe",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Get List By Title

This method allows you to retrieves a List by List title.

getListByTitle
<sharepoint.getListByTitle>
    <title>{$ctx:title}</title>
</sharepoint.getListByTitle>
Properties
  • title : The title of the list to return.

Sample request

Following is a sample REST request that can be handled by the getListById operation.

getListByTitle
{ 
  "apiUrl":"https://xxx.sharepoint.com",
  "title":"BillInfoList",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Delete a list

This method allows you to delete a list in site.

deleteList
<sharepoint.deleteList>
    <title>{$ctx:title}</title>
    <ifMatch>{$ctx:ifMatch}</ifMatch>
</sharepoint.deleteList>
Properties
  • title : Title of the list to delete.

  • ifMatchTo force an overwrite of the item regardless of version, set the  ETag  value to  "*".
Sample request

Following is a sample REST request that can be handled by the deleteList operation.

deleteList
{
  "apiUrl":"https://xxx.sharepoint.com",
  "title":"BillInfoList",
  "ifMatch":"*",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Retrieves all the Lists items

This method allows you to retrieves all the lists items in the list in the site.

retriveListItems
<sharepoint.retriveListItems>
    <title>{$ctx:title}</title>
</sharepoint.retriveListItems>
Properties
  • title:  The title of the list to return all list items.

Sample request

Following is a sample REST request that can be handled by the retriveListItem operation.

retriveListItems
{
  "apiUrl":"https://xxx.sharepoint.com",
  "title":"BillInfoList",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Create a list item

This method allows you to create a list item.

createListItem
<sharepoint.createListItem>
    <title>{$ctx:title}</title>
    <type>{$ctx:type}</type>
    <listTitle>{$ctx:listTitle}</listTitle>
</sharepoint.createListItem>
Properties
  • type  :  The type of list item to be created (eg:-  SP.Data.Team_x0020_tasksListItem)  
  • title:  The name of the list item to be created.

  • listTitle:  The title of the list where the item to be created (eg:- Team_x0020_tasks).

Sample request

Following is a sample REST request that can be handled by the createListItem operation.

createListItem
{ 
  "apiUrl":"https://xxx.sharepoint.com",
  "type":"SP.Data.BillInfoListListItem",
  "title": "Item1",
  "listTitle":"BillInfoList",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Update a list

This method allows you to update a list in the site.

updateList
<sharepoint.updateList>
    <guId>{$ctx:guId}</guId>
    <title>{$ctx:title}</title>
    <type>{$ctx:type}</type>
    <ifMatch>{$ctx:ifMatch}</ifMatch>
</sharepoint.updateList>
Properties
  • guId:  The GUID of the list.
  • type: Type use when constructing the metadata variable.
  • title: The title of the list to create.
  • ifMatch: To force an overwrite of the item regardless of version, set the ETag value.

Sample request

Following is a sample REST request that can be handled by the updateList operation.

updateList
{
  "apiUrl":"https://xxx.sharepoint.com",
  "guId":"14cf6f8b-5db4-4fb7-af20-07e058b3bcfe",
  "title":"BillInfoListupdated",
  "type":"SP.List",
  "ifMatch":"*",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Get list item by ID

This method allows you to retrieves list item with specified ID.

getItemById
<sharepoint.getItemById>
    <title>{$ctx:title}</title>
    <itemId>{$ctx:itemId}</itemId>
</sharepoint.getItemById>
Properties
  • title : The title of the list.

  • itemId: The ID of the list item to return.

Sample request

Following is a sample REST request that can be handled by the getItemById operation.

getItemById
{ 
  "apiUrl":"https://xxx.sharepoint.com",
  "title": "BillInfoList",
  "itemId": "3",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Delete a list item

This method allows you to delete a list item in site.

deleteListItem
<sharepoint.deleteListItem>
    <title>{$ctx:title}</title>
    <itemId>{$ctx:itemId}</itemId>
    <ifMatch>{$ctx:ifMatch}</ifMatch>
</sharepoint.deleteListItem>
Properties
  • title : Title of the list to delete.

  • itemIdThe GUID of the list item.
  • ifMatchTo force an overwrite of the item regardless of version, set the  ETag  value to  "*".
Sample request

Following is a sample REST request that can be handled by the deleteListItem operation.

deleteListItem
{
  
  "apiUrl":"https://xxx.sharepoint.com",
  "itemId":"2",
  "title":"BillInfoList",
  "ifMatch":"*",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Update a list item

This method allows you to update a list item in the site.

updateListItems
<sharepoint.updateListItems>
    <title>{$ctx:title}</title>
    <type>{$ctx:type}</type>
    <newTitle>{$ctx:newTitle}</newTitle>
    <itemId>{$ctx:itemId}</itemId>
    <ifMatch>{$ctx:ifMatch}</ifMatch>
</sharepoint.updateListItems>
Properties
  • title:  The title of the list.
  • type: Type use when constructing the metadata variable.
  • newTitle: The new title of item to update.
  • itemIdThe ID of the list item to update.
  • ifMatch: To force an overwrite of the item regardless of version, set the ETag value.

Sample request

Following is a sample REST request that can be handled by the updateListItems operation.

updateListItems
{ 
  "apiUrl":"https://wso.sharepoint.com",
  "itemId":"3",
  "title":"BillInfoList",
  "type":"SP.Data.BillInfoListListItem",
  "newTitle":"updatedItem1",
  "ifMatch":"*",
  "accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "blocking":"true"
}

Create Custom List Item

 This method allows you to create custom(dynamic) List Item.

createCustomListItem
<sharepoint.createCustomListItem>
   <customListItems>{$ctx:customListItems}</customListItems>
   <type>{$ctx:type}</type>
   <listTitle>{$ctx:listTitle}</listTitle>
</sharepoint.createCustomListItem>
Properties
  • listTitle: The title of the custom list.
  • type: Type use when constructing the metadata variable.
  • customListItems: The list of items to be created.

Sample request

Following is a sample REST request that can be handled by the createCustomListItem operation.

createCustomListItem
{ 
  "apiUrl":"https://xxx.sharepoint.com",
  "type":"SP.Data.Custom002ListItem",
  "customListItems":{"Title": "Item_005.1", "Add_Col":"john", "mobileNo":"0752676124", "FirstName":"Miller", "LastName":"John", "Address":"Batticalo"},
  "listTitle":"Custom002",
  "blocking":"true",
  "accessToken":"eyJ0eXAiOixxxxxxxxxxxxx"
}

Sample configuration

Following is a sample proxy service that illustrates how to connect to SharePoint with the init operation and use the createList operation. The sample request for this proxy can be found in createList sample request. You can use this sample as a template for using other operations in this category.

Sample Proxy
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="createList"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence>
        <property name="id" expression="json-eval($.id)"/>
		<property name="clientId" expression="json-eval($.clientId)"/>
		<property name="clientSecret" expression="json-eval($.clientSecret)"/>
		<property name="refreshToken" expression="json-eval($.refreshToken)"/>
		<property name="redirectUri" expression="json-eval($.redirectUri)"/>
		<property name="resource" expression="json-eval($.resource)"/>
		<property name="code" expression="json-eval($.code)"/>
		<property name="apiUrl" expression="json-eval($.apiUrl)"/>
		<property name="accessToken" expression="json-eval($.accessToken)"/>
		<property name="type" expression="json-eval($.type)"/>
		<property name="allowContentTypes" expression="json-eval($.allowContentTypes)"/>
		<property name="baseTemplate" expression="json-eval($.baseTemplate)"/>
		<property name="contentTypesEnabled"
          expression="json-eval($.contentTypesEnabled)"/>
		<property name="description" expression="json-eval($.description)"/>
		<property name="title" expression="json-eval($.title)"/>
        <property name="blocking" expression="json-eval($.blocking)"/>
        <sharepoint.init>
    		<apiUrl>{$ctx:apiUrl}</apiUrl>
    		<accessToken>{$ctx:accessToken}</accessToken>
   			<id>{$ctx:id}</id>
    		<clientId>{$ctx:clientId}</clientId>
    		<clientSecret>{$ctx:clientSecret}</clientSecret>
    		<refreshToken>{$ctx:refreshToken}</refreshToken>
    		<redirectUri>{$ctx:redirectUri}</redirectUri>
    		<resource>{$ctx:resource}</resource>
    		<registryPath>{$ctx:registryPath}</registryPath>
    		<intervalTime>{$ctx:intervalTime}</intervalTime>
            <blocking>{$ctx:blocking}</blocking>
		</sharepoint.init>
        <sharepoint.createList>
    		<type>{$ctx:type}</type>
    		<allowContentTypes>{$ctx:allowContentTypes}</allowContentTypes>
    		<baseTemplate>{$ctx:baseTemplate}</baseTemplate>
    		<contentTypesEnabled>{$ctx:contentTypesEnabled}</contentTypesEnabled>
    		<description>{$ctx:description}</description>
    		<title>{$ctx:title}</title>
		</sharepoint.createList>
         <respond/>
      </inSequence>
      <outSequence>
         <log/>
         <send/>
      </outSequence>
   </target>
   <parameter name="serviceType">proxy</parameter>
</proxy>