class ListItemCreationInformationUsingPath
A data class that encapsulates the properties required to create a new list item in SharePoint, including its name, type, and folder location.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/listitems/creation_information_using_path.py
5 - 22
simple
Purpose
This class serves as a data transfer object (DTO) for specifying the creation parameters of a new SharePoint list item. It inherits from ClientValue, making it suitable for serialization and transmission to SharePoint services. The class is particularly useful when creating items in document libraries or lists where you need to specify the item's name, object type (file or folder), and the parent folder path. It handles automatic conversion of folder paths to SPResPath objects for proper SharePoint resource path handling.
Source Code
class ListItemCreationInformationUsingPath(ClientValue):
def __init__(self, leaf_name, object_type, folder_path=None):
"""
Specifies the properties of the new list item.
:param str leaf_name: Specifies the name of the list item that will be created. In the case of a document
library, the name is equal to the filename of the list item.
:param int object_type: Specifies the file system object type for the item that will be created.
:param str or SPResPath folder_path: Specifies the path of the folder of the new list item.
"""
super(ListItemCreationInformationUsingPath, self).__init__()
self.LeafName = leaf_name
self.UnderlyingObjectType = object_type
self.FolderPath = (
folder_path
if isinstance(folder_path, SPResPath)
else SPResPath(folder_path)
)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
leaf_name: The name of the list item to be created. For document libraries, this corresponds to the filename. This is a required string parameter that identifies the new item within its parent folder.
object_type: An integer value specifying the file system object type for the item being created. Typically represents whether the item is a file (0) or folder (1) in SharePoint's object model.
folder_path: Optional parameter specifying the path of the parent folder where the new list item will be created. Can be provided as either a string path or an SPResPath object. If provided as a string, it will be automatically converted to an SPResPath object. If None, the item will be created in the default location.
Return Value
Instantiation returns a ListItemCreationInformationUsingPath object with three attributes: LeafName (str), UnderlyingObjectType (int), and FolderPath (SPResPath). This object is typically used as a parameter for SharePoint list item creation operations and is serialized by the ClientValue base class for transmission to SharePoint services.
Class Interface
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
LeafName |
str | The name of the list item to be created. In document libraries, this is the filename. | instance |
UnderlyingObjectType |
int | The file system object type for the item (0 for file, 1 for folder). | instance |
FolderPath |
SPResPath | The SharePoint resource path object representing the parent folder location where the item will be created. | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
from office365.sharepoint.types.resource_path import ResourcePath as SPResPath
Usage Example
from office365.runtime.client_value import ClientValue
from office365.sharepoint.types.resource_path import ResourcePath as SPResPath
from office365.sharepoint.listitems.creation_information_using_path import ListItemCreationInformationUsingPath
# Create a new document in a specific folder
creation_info = ListItemCreationInformationUsingPath(
leaf_name="NewDocument.docx",
object_type=0, # 0 for file, 1 for folder
folder_path="/sites/mysite/Shared Documents/MyFolder"
)
# The folder_path is automatically converted to SPResPath
print(creation_info.LeafName) # Output: NewDocument.docx
print(creation_info.UnderlyingObjectType) # Output: 0
print(type(creation_info.FolderPath)) # Output: <class 'SPResPath'>
# Create without specifying folder (uses default location)
creation_info_default = ListItemCreationInformationUsingPath(
leaf_name="AnotherDocument.docx",
object_type=0
)
# Use with SharePoint list to create an item
# list_obj.add_using_path(creation_info)
Best Practices
- Always provide a valid leaf_name that follows SharePoint naming conventions (avoid special characters like /, \, :, *, ?, ", <, >, |)
- Use object_type=0 for files and object_type=1 for folders to match SharePoint's file system object type enumeration
- When providing folder_path as a string, ensure it uses forward slashes and represents a valid SharePoint server-relative or site-relative path
- The class automatically handles conversion of string paths to SPResPath objects, so either format is acceptable for folder_path
- This object is immutable after creation - create a new instance if you need different parameters
- The class is designed to be used as a parameter for SharePoint list item creation methods, not as a standalone data store
- Ensure the folder_path exists in SharePoint before attempting to create items in it, or the creation operation will fail
- This class inherits from ClientValue, which means it can be serialized for transmission to SharePoint REST or CSOM endpoints
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class ListItemCreationInformation 94.2% similar
-
class ContentTypeCreationInformation 73.6% similar
-
class GroupCreationInformation_v1 72.6% similar
-
class CreatableItemInfo 72.2% similar
-
class FileCreationInformation 71.0% similar