pypi Office365-REST-Python-Client 2.1.9
v 2.1.9

latest releases: 2.5.9, 2.5.8, 2.5.7...
3 years ago

The list of changes

  • initial support for Microsoft Teams API
  • improved support for working with paged data
  • introduced support for certificate authentication for SharePoint API
  • improvements and model updates for SharePoint and OneDrive APIs

and more

Initial support for [Microsoft Teams API

The support for Microsoft Teams API has been introduced, the following example demonstrates how how create a new team under a group which corresponds to Create team endpoint

tenant_name = "contoso.onmicrosoft.com"
client = GraphClient(tenant_name, get_token)
new_team = client.groups[group_id].add_team()
client.execute_query()

where

def get_token(auth_ctx):
    """Acquire token via client credential flow (ADAL Python library is utilized)
    :type auth_ctx: adal.AuthenticationContext
    """
    token = auth_ctx.acquire_token_with_client_credentials(
        "https://graph.microsoft.com",
        client_id,
        client_secret)
    return token

Improved support for working with paged data

Here is an example which demonstrates how to retrieve data from a SharePoint list which contains more then 5k items:

def print_progress(items_read):
    print("Items read: {0}".format(items_read))


ctx = ClientContext.connect_with_credentials(site_url,
                                             ClientCredential(client_id,client_secret))

list_source = ctx.web.lists.get_by_title("Contacts_Large")
items = list_source.items
items.page_loaded += print_progress  # page load event
items.page_size = 400  # specify custom page size (default is 100)
ctx.load(items)
ctx.execute_query()

#print("Items count: {0}".format(len(items)))
for item in items:
    print("{0}".format(item.properties['Title']))

Support for certificate authentication for SharePoint API

The example demonstrates how to connect to SharePoint Online with certificate credentials:

ctx = ClientContext.connect_with_certificate(site_url,
                                             client_id,
                                             thumbprint,
                                             certificate_path)

current_web = ctx.web
ctx.load(current_web)
ctx.execute_query()
print("{0}".format(current_web.url))

Refer how-to page for a more details

Improvements and model updates for SharePoint and OneDrive APIs

In terms of file and folder operations the following methods have been introduced:

  • File.download(file_object) - download a file content into a file object (SharePoint API)
  • Folder.copyto(new_folder_url, overwrite) - copy a folder (SharePoint API)
  • Folder.moveto(new_folder_url, flags) move a folder (SharePoint API)
  • DriveItem.download(file_object) - downloads a file content into a file object (OneDrive API)
  • DriveItem.get_content() - downloads a file content (OneDrive API)

Don't miss a new Office365-REST-Python-Client release

NewReleases is sending notifications on new releases.