MS SharePoint – Lists – Get List Items

Estimated reading: 7 minutes

MS SharePoint – Lists – Get List Items

Retrieves records from a list, automatically expanding fields. Item Fields restricts which field values are expanded; blank Item Fields requests all fields. Additional Expand values are merged with the fields expansion. Filter uses Microsoft OData syntax, including fields/internalColumnName where supported; indexed-column constraints still apply.

Action details

PropertyValue
Action labelMS SharePoint – Lists – Get List Items
CategoryCloudTools
Apex class and methodGetSharePointListItems.getListItems
Input typeGetSharePointListItems.GetSharePointListItemsInput
Output typeList<List<SharePointListItem>>
AuthorizationOAuth Delegated (Authorization Code) or OAuth Application (Client Credentials), subject to endpoint restrictions.
Microsoft Graph requestGET /v1.0/sites/{siteId}/lists/{listId}/items

Prerequisites and permissions

Configure a CloudTools Connector with Connector Type set to Microsoft 365. Complete user sign-in for delegated access. For supported application access, grant application permissions and administrator consent. The calling identity must have access to the relevant site, list, library, or item; tenant policy and resource configuration still apply.

The action permission provider declares the following permission alternatives. These are not cumulative requirements and not all are least privileged. Check the linked Microsoft reference for the endpoint, authorization type, and current restrictions.

Permission typeDeclared alternatives
DelegatedSites.Read.All, Sites.ReadWrite.All
ApplicationSites.Read.All, Sites.ReadWrite.All

See the Microsoft operation and permissions reference.

Inputs

Supply one non-null request with nonblank required identifiers. IDs must belong to the indicated site, list, or drive; do not substitute Salesforce IDs or browser URLs.

InputApex fieldTypeRequiredDescription
Site IdsiteIdStringYesSharePoint site identifier.
List IdlistIdStringYesSharePoint list identifier.
FilterfilterQueryStringNoOData filter expression. Supply the OData value only, without a query parameter name or full URL. Microsoft validates supported values.
SelectselectQueryStringNoComma-delimited list item properties to select. Supply the OData value only, without a query parameter name or full URL. Microsoft validates supported values.
Item FieldsitemFieldsStringNoComma-delimited list item fields to include in fields(Select=…). Supply internal column names, comma-separated, without fields($select=…).
ExpandexpandQueryStringNoComma-delimited expansions (for example fields,driveItem). Supply the OData value only, without a query parameter name or full URL. Microsoft validates supported values.

The global invocable input does not expose connectorId. Direct subscriber Apex and Flow calls use CloudTools connector selection. Resolve dynamic values before invocation; this action does not resolve replacement tokens.

Outputs

Returns one outer result containing the resource collection for the first request. In Apex, read results[0]; Flow receives the collection output. The LWC library returns a flat array.

The implementation maps the response collection without following or exposing @odata.nextLink. Results can contain only the first page. Top, where exposed, controls the requested page size rather than guaranteeing complete retrieval. There is no continuation URL input.

OutputApex fieldTypeDescription
IdidStringUnique identifier for the list item.
NamenameStringName of the list item.
DescriptiondescriptionStringDescription of the list item.
Created Date TimecreatedDateTimeStringCreated date and time for the list item.
Last Modified Date TimelastModifiedDateTimeStringLast modified date and time for the list item.
Web URLwebUrlStringWeb URL of the list item.
ETageTagStringEntity tag for optimistic concurrency.
OData TypeodataTypeStringOData type for the list item.
OData ETagodataEtagStringOData ETag for the list item.
Created BycreatedBySharePointIdentitySetIdentity set representing who created the item.
Last Modified BylastModifiedBySharePointIdentitySetIdentity set representing who last modified the item.
Parent ReferenceparentReferenceSharePointParentReferenceParent reference for the item.
Content TypecontentTypeSharePointCTInfoContent type for the list item.
FieldsfieldsSharePointFieldValueSetList item field values.
Drive ItemdriveItemMSGraphDriveItemRelated drive item if one exists.
VersionsversionsList<SharePointVersion>Versions for this list item.
Document Set VersionsdocumentSetVersionsList<SharePointDocumentSetVersion>Document set versions for this list item.
SharePoint IDssharepointIdsSharePointIdsSharePoint identifier set for the list item.
Additional PropertiesadditionalPropertiesList<DynamicObject>Additional properties from user-defined query.

Field values are available through fields.additionalData as DynamicObject name/value entries. Normal response mapping also retains flattened and extra properties in additionalProperties. Update List Item is an exception: it constructs only id and fields from the fieldValueSet response. Related driveItem, versions, and documentSetVersions are populated only when Microsoft returns them.

Use in Flow

Add MS SharePoint – Lists – Get List Items in Flow Builder. Use a Microsoft 365 application connector configured as Set as default for Flow automations, supply the required resource IDs, and add fault handling. Delegated connections are not supported for CloudTools Flow automation. This implementation processes only the first input request and is not a bulk operation.

Use in custom Apex

This subscriber-org example uses the Apptigent namespace. Replace the identifiers, configure the connector, and run in a context that permits callouts. Arrange authorization before calling and handle exceptions in the caller.

Apptigent.GetSharePointListItems.GetSharePointListItemsInput request =
    new Apptigent.GetSharePointListItems.GetSharePointListItemsInput();
request.siteId = 'REPLACE_WITH_SITE_ID';
request.listId = 'REPLACE_WITH_LIST_ID';

List<List<Apptigent.SharePointListItem>> results =
    Apptigent.GetSharePointListItems.getListItems(
        new List<Apptigent.GetSharePointListItems.GetSharePointListItemsInput>{ request }
    );

List<Apptigent.SharePointListItem> items = results.isEmpty()
    ? new List<Apptigent.SharePointListItem>() : results[0];
System.debug(items.size());

Use in a Lightning Web Component

Use getSharePointListItems from msSharePointConnectorLib, through MSSharePointConnectorController. These c/ imports apply to an LWC in the same namespace. The function accepts one request object, including connectorId when applicable.

Set request.connectorId to select a configured Connector record. The controller passes this request selection through SharePointAction. The field belongs to the controller request, not the global invocable input type.

sharePointActionExample.js

import { LightningElement } from 'lwc';
import { getSharePointListItems, MSSharePointObjects } from 'c/msSharePointConnectorLib';

export default class SharePointActionExample extends LightningElement {
    connectorId = 'REPLACE_WITH_CONNECTOR_RECORD_ID';
    result = null;
    errorMessage = '';
    isRunning = false;
    completed = false;

    async handleRun() {
        if (this.isRunning) {
            return;
        }
        this.isRunning = true;
        this.errorMessage = '';
        try {
            const request = MSSharePointObjects.inputs.listItem();
            request.connectorId = this.connectorId;
            request.siteId = 'REPLACE_WITH_SITE_ID';
            request.listId = 'REPLACE_WITH_LIST_ID';
            const result = await getSharePointListItems(request);
            if (!Array.isArray(result)) {
                throw new Error('The action did not return a usable result.');
            }
            this.result = result;
            this.completed = true;
        } catch (error) {
            this.errorMessage = error.requiresInteractiveAuthorization
                ? 'Sign in to Microsoft for the connector, then try again.'
                : error.message || 'The SharePoint action failed.';
        } finally {
            this.isRunning = false;
        }
    }
}

sharePointActionExample.html

<template>
    <lightning-button label="Run action" onclick={handleRun}
        disabled={isRunning}></lightning-button>
    <p role="alert">{errorMessage}</p>
</template>

The library resolves to a flat array without the outer Apex collection.

The controller exposes fieldsJson containing a JSON object of field values, plus flattened identity, parent, content-type, and drive-item metadata. Update List Item only supplies the returned fields and input ID; retrieve the record separately if full metadata is needed.

LWC rawJson serializes the mapped Apex object; it is not the untouched Microsoft response or an additional global invocable output. Use getMSSharePointAuthorizationState, beginMSSharePointAuthorization, and createMSSharePointOAuthMessageHandler to arrange delegated sign-in. The library normalizes controller errors, including requiresInteractiveAuthorization when available; it does not automatically sign in or retry.

Error handling and troubleshooting

SymptomWhat to check
Required fields errorSupply a nonempty request list, a non-null first request, and the required identifiers or body values.
Authorization or access deniedCheck connector selection, sign-in, application versus delegated permissions, administrator consent, and resource access.
Resource not foundVerify the parent site, list, and drive IDs. Distinguish list item IDs from drive item IDs and retain permission or version IDs with their resource.
Missing fields or itemsCheck query inputs, first-page behavior, supported expansions, item type, and mapped output limitations.
Unexpected connectorReview the connector selection behavior described above and the Microsoft 365 default connector.
Operation rejectedInspect the Microsoft error, JSON field values, library or page state, supported API capabilities, and tenant policies.
Share this Doc

MS SharePoint – Lists – Get List Items

Or copy link

CONTENTS

Free eBook: The Ultimate Guide to Power Platform Custom Connectors

Antimanual

Ask our AI support assistant your questions about our platform, features, and services.

You are offline
Chatbot avatar
What can I help you with?

Subscribe

×
Cancel