Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'SharePointSession' object has no attribute 'cookie' #69

Open
hiimani28 opened this issue Jul 29, 2022 · 0 comments
Open

Comments

@hiimani28
Copy link

hiimani28 commented Jul 29, 2022

`

    authcookie = Office365(base_path, username=username, password=password).GetCookies()
    session = requests.Session()
    session.cookies = authcookie
    session.headers.update({'user-agent': 'python_bite/v1'})
    session.headers.update({'accept': 'application/json;odata=verbose'})
    
    session.headers.update({'X-RequestDigest': 'FormDigestValue'})
    response = session.post(url = base_path + "/sites/" + site_name + "/_api/web/GetFolderByServerRelativeUrl('" + doc_library + "')/Files/add(url='a.txt',overwrite=true)",
                            data="")
    session.headers.update({'X-RequestDigest': response.headers['X-RequestDigest']})
    # perform the actual upload
    with open(file_name_1, 'rb') as file_input:
       
        response = session.post( url = base_path + "/sites/" + site_name + "/_api/web/GetFolderByServerRelativeUrl('" + doc_library + "')/Files/add(url='"+ tail + "',overwrite=true)",data=file_input)
    return True

`

I keep getting the below mentioned error, been stuck on this since 2 days

  • ERROR - upload failed because of 'SharePointSession' object has no attribute 'cookie'
    Traceback (most recent call last):
    File "sharepointTEST.py", line 58, in upload_to_sharepoint
    p = s.post(base_path+"/sites/"+site_name+"/_api/web/folders",
    File "C:\Program Files\Python38\lib\site-packages\sharepy\session.py", line 150, in post
    kwargs["headers"]["Authorization"] = "Bearer " + self._redigest()
    File "C:\Program Files\Python38\lib\site-packages\sharepy\session.py", line 126, in _redigest
    data="", headers={"Cookie": self.cookie})
    AttributeError: 'SharePointSession' object has no attribute 'cookie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant