Caml Query not working using Python on sharepoint Online

I am using Python to get the data from share point. I want to extract particular rows or data which has Status = "Submitted".

For that i have written below code but i am not sure why am i getting error.

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.listitems.caml.caml_query import CamlQuery
from office365.runtime.auth.user_credential import UserCredential

baseurl = ''
basesite = '/teams/ia/Powerappsdatabase/' # every share point has a home.
siteurl = baseurl + basesite 

sp_list = "HCFM_Projects"
ctx = ClientContext(siteurl).with_credentials(UserCredential("", "password"))
sp_lists = ctx.web.lists
s_list = sp_lists.get_by_title(sp_list)

query_text = 
            <FieldRef Name="Status" />
                <Value Type="Choice">Submitted</Value>

caml_query = CamlQuery.parse(query_text)
items = s_list.get_items(caml_query)

But I am getting error ClientRequestException: ('-2130575252, System.Runtime.InteropServices.COMException', 'The security validation for this page has timed out. Click Back in your Web browser, refresh the page, and try your operation again.', "403 Client Error: FORBIDDEN for url:'HCFM_Projects')/GetItems")

Read more here:

Content Attribution

This content was originally published by Akshi at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: