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

TypeError: expected str instance, RequestOptions found #612

Closed
sant3e opened this issue Dec 5, 2022 · 1 comment
Closed

TypeError: expected str instance, RequestOptions found #612

sant3e opened this issue Dec 5, 2022 · 1 comment
Labels

Comments

@sant3e
Copy link

sant3e commented Dec 5, 2022

I'm trying to get the list items in a json format and then dump it in a dataframe
I am having trouble right from the start with the RequestOptions module. Not sure if it's something on my end or with any part of the REST Client

url = "https://mydomain.sharepoint.com/sites/sa/Resources/sfs/_api/Web/lists/GetByTitle('tile with spaces')/items"
request= RequestOptions(url)
response=ctx.execute_request_direct(request)
data = json.loads(response.content)
list_items.extend(data['d']['results'])

I am getting this error:

Exception has occurred: TypeError       (note: full exception trace is shown but execution is paused at: <module>)
sequence item 2: expected str instance, RequestOptions found
  File "C:\user\Projects\newapp\Tests.py", line 57, in <module> (Current frame)
    response = ctx.execute_request_direct(request)

I've tried adjusting the url by removing parts of it (without items, without GetByTitle) but no luck

@vgrem vgrem added the bug label Dec 10, 2022
vgrem added a commit that referenced this issue Jun 9, 2024
@vgrem
Copy link
Owner

vgrem commented Jun 26, 2024

Starting from version 2.5.11, a separate client (SharePointRequest class) has been introduced, intended for working with the API without involving a model. For example:

import json
from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.request import SharePointRequest
site_url = "https://{your-tenant-prefix}.sharepoint.com"
request = SharePointRequest(site_url).with_credentials(UserCredential("{username}", "{password}"))
response = request.execute_request("web")
json = json.loads(response.content)
web_title = json['d']['Title']
print("Web title: {0}".format(web_title))

@vgrem vgrem closed this as completed Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants