Python office365.sharepoint.listitems.caml.query Caml query returns wrong rows

316 views Asked by At

I am trying to search for an image on SharePoint Photo Library, but I keep print out same incorrect results even when I change the file_name it will print out the same result.and also it print only 55 rows

shared_docs = ctx.web.lists.get_by_title(library_title)
caml_query = CamlQuery.create_all_folders_query()
caml_query.ViewXml = f"<View><Query><Where><Contains><FieldRef Name='FileLeafRef'/><Value Type='Text'>{file_name}</Value></Contains></Where></Query></View>"
items = shared_docs.get_items(caml_query)
ctx.load(items)
ctx.execute_query()

for item in items:
    file = item.file
    ctx.load(file)
    ctx.execute_query()
    if file.serverRelativeUrl is not None:
        file_url = file.serverRelativeUrl
        print(file_url)

I was changing the Field to Title and change the file_name change Contanins to Eq. nothing can change the print result. even trying this caml_query.parse("") the result still not change

0

There are 0 answers