Reputation: 64
I am trying to get all the list items from a sharepoint list. I am using python msal library. When I am using this
url = f"{base_url}/sites/{site_id}/lists/{lists_id}/columns
, I am getting around 63 different columns which also contains User Created By
column. But when I am using this url: url = f"{base_url}/sites/{site_id}/lists/{lists_id}/items?$expand=fields
, I unable to find that in the json reply. but instead it contains UserCreatedByLookupId
. I was trying to go through this link , but unable to understand how can I get the actual value. because when I am hitting this url {base_url}/sites/{site_id}/lists/{lists_id}/items?$expand=fields(select=UserCreatedBy)
it through error: Exception: Error fetching lists: {"error":{"code":"BadRequest","message":"Parsing OData Select and Expand failed: Term '(select=UserCreatedBy)' is not valid in a $select or $expand expression.","innerError"
this UserCreatedByLookupId
is present in fields
. can someone please help me out here?
Requested screenshot of columns:
Upvotes: 0
Views: 72
Reputation: 16054
For sample, I created columns in SharePoint like below:
To get the UserCreatedBy
value you need to pass $select
instead of select
as suggested by @user2250152:
https://graph.microsoft.com/v1.0/sites/SiteID/lists/ListID/items/ItemID?$expand=fields($select=UserCreatedBy)
To expand all the columns, use the below query:
GET https://graph.microsoft.com/v1.0/sites/SiteID/lists/ListID/items/ItemID?$expand=fields
Upvotes: 0