I can successfully connect via a defined app (with Client ID und Secret) to my Sharepoint Online using Office365-REST-Python-Client package in Python.
I have tried to change the language via the header:
from office365.sharepoint.client_context import ClientContext
from office365.runtime.http.request_options import RequestOptions
# SharePoint-URL und Authentifizierungsdetails
site_url = "https://site"
client_id = "clientid"
client_secret = "secret"
credentials = ClientCredential(client_id, client_secret)
ctx = ClientContext(site_url).with_credentials(credentials)
# Sprache auf Deutsch setzen
request = RequestOptions(ctx.service_root_url)
request.ensure_header("Accept-Language", "de-DE") # Sprachpräferenz einstellen
# Abfrage der Listen
lists = ctx.web.lists.get().execute_query()
# Displaynamen der Listen ausgeben
for sp_list in lists:
print(f"Listenname: {sp_list.properties['Title']}")
But the listnames (Title) are still returned in english. In general the request should be dynamic, because some site-collections are in english, others are in german. Therefore it’s important to set the language in the python script so the right display names are returned.
So how can the language in the REST API be set?
1