Better way to handle SharePoint List Item CRUD Operations using Next-Level endpoints

Unlock SharePoint list item CRUD operations by leveraging next-level REST API endpoints, enabling precise control and enhanced functionality in data management.

SharePoint, as a powerful collaboration platform, offers a wide array of functionalities to manage data effectively. When it comes to manipulating list items, CRUD operations are fundamental. Traditionally, developers have relied on standard REST API endpoints for these operations. However, there exists a next level of SharePoint REST API integration that unlocks advanced capabilities, offering alternative endpoints for CRUD operations. Let’s dive into these advanced methods step by step.

Create List Item

Standard Endpoint

https://<tenant>.sharepoint.com/_api/web/lists/GetByTitle(‘ListName’)/items

Next-level Endpoint:

 https://<tenant>.sharepoint.com/_api/web/lists/GetByTitle(‘ListName’)
/AddValidateUpdateItemUsingPath
  • This advanced method allows for creating list items not just at the root level but also within specific folders.
  • In case of failure, the response includes detailed error messages specifying the problematic column.
Type Standard Endpoint Next-Level Endpoint
Method POST POST
Headers Accept:application/json;odata=verbose
Content-Type: application/json;odata=verbose
Accept:application/json;odata=verbose
Content-Type: application/json;odata=verbose
Body
{
  "_metadata": {
    "type": "SP.Data.ListNameListItem"
  },
  "Title": "First List Item"
}

 

 

{
  "listItemCreateInfo": {
    "__metadata": {
      "type": "SP.ListItemCreationInformationUsingPath"
    },
    "FolderPath": {
      "__metadata": {
        "type": "SP.ResourcePath"
      },
      "DecodedUrl": "/sites/sitename/Lists/ListName"
    }
  },
  "formValues": [
    {
      "FieldName": "Title",
      "FieldValue": "Sample Title"
    }
  ]
}

Read List Item

Standard Endpoint

https://<tenant>.sharepoint.com/_api/web/lists/GetByTitle(‘ListName’)/items(<ItemID>)

Next-level Endpoint:

https://<tenant>.sharepoint.com/sites/<sitename>/_api/web/lists/GetByTitle(‘ListName’)
/RenderExtendedListFormData(itemId=2,formId='editform',mode='2',options=30,cutoffVersion=0)
  • This endpoint not only retrieves list item properties, but also provides details on available columns, form structure and more.
Type Standard Endpoint Next-Level Endpoint
Method GET POST
Headers Accept:application/json;odata=verbose
Content-Type: application/json;odata=verbose
Accept:application/json;odata=verbose
Content-Type: application/json;odata=verbose

Update List Item

Standard Endpoint:

https://<tenant>.sharepoint.com/_api/web/lists/GetByTitle(‘ListName’)/items(<ItemID>)

Next-Level Endpoint:

https://<tenant>.sharepoint.com/_api/web/lists/GetByTitle('ListName')/GetItemById(<ItemID>)
/ValidateUpdateListItem()
  • Utilize this endpoint to update specific properties of a list item identified by its ID.
  • The ValidateUpdateListItem method ensures that updates are consistent and error-free.
  • When-ever error appear on updating the item, the response data throws error on specific field data
Type Standard Endpoint Next-Level Endpoint
Method POST POST
Headers Accept:application/json;odata=verbose
Content-Type: application/json;odata=verbose
If-Match: {eTag or *}
X-HTTP-Method: Merge
Accept:application/json;odata=verbose
Content-Type: application/json;odata=verbose
Body
{
  "_metadata": {
    "type": "SP.Data.ListNameListItem"
  },
  "Title": "Update First List Item"
}
{
  "formValues": [
    {
      "FieldName": "Title",
      "FieldValue": "Update Sample Title"
    }
  ]
}

Delete List Item

Standard Endpoint:

https://<tenant>.sharepoint.com/_api/web/lists/GetByTitle('ListName')/items(<ItemID>)

Next-Level Endpoint:

https://<tenant>.sharepoint.com/_api/web/lists/GetByTitle('ListName')/GetItemById(<ItemID>)
/recycle
Type Standard Endpoint Next-Level Endpoint
Method POST POST
Headers If-Match: {eTag or *}
X-HTTP-Methiod: “Delete”
  • Removes the list item from the list or library and send the item to the recycle bin, allowing for potential recovery if needed.

By leveraging these next-level endpoints, developers can elevate their SharePoint development, enabling more precise control and enhanced functionality in managing list items.

 

Shantha Kumar
Shantha Kumar
Articles: 280