I ask a similar question but I asked it slightly wrong, thus asking a second question more geared at my issue.
I have a list with custom fields/columns in it and I need to retrieve that data that is in one of the custom fields/columns. However, when I am retrieving the items of the list none of my custom columns/fields are not showing up in the fields list of the object.
List<QueryOption> queryExpandFields = new List<QueryOption> { new QueryOption("$expand", "fields") };
IListItemsCollectionPage items = await GraphClient.Sites[sharepointSessionId].Lists[listName].Items.Request(queryExpandFields).GetAsync();
The code above grabs the items in the list however, as mentioned, none of my columns/fields are in the list.
For example
List Name: ListNameTest
Columns: TestColumn1, TestColumn2, TestColumn3, TestColumnId
Data: TestColumn1: "Dog", TestColumn2: 2021, TestColumn3: "January", TestColumnId: 001
In my code I need to grab the Items in the list and retrieve the data that is in the TestColumnId for example.
On the graph-explorer site I have tried the following end point. And in here I do see my custom column list in the columns, but when I look at the Items, I do not see the column listed in the fields section of the item (or anywhere else in the item)
GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}?expand=columns,items(expand=fields)
My overall purpose is to grab the items from the list, do a parse on the TestColumnId as this is data that is populated from a database. Grab the unique id that I populated in my custom column (TestColumnId) to get the ID value of that item in the list. This ID value will then be passed to a secondary List to populate the Lookup id that has the first list as a sub list in the second list.
Now I have all of this code set up, I have it working if I hard code the values, but I need this one last piece to work.
Edit:
I finally figured out what the issue was! in the QueryOptions I had to do a selection on the exact column i wanted.
var queryOptions = new List<QueryOption>()
{
new QueryOption("expand", "fields(select=ColumnName)")
};
var items2 = await GraphClient.Sites[siteid].Lists[listid].Items
.Request(queryOptions)
.GetAsync();