I have a simple fetch I am using to GET items from a specific SharePoint list.
When I specify what fields I want to GET with _api/lists/getbytitle('ListName')/items?$select=Name,Item2,Item3,Item4,etc. I get an error logged in my console telling me:
code: "-1, Microsoft.SharePoint.SPException"
message: {lang: "en-US",…}
lang: "en-US"
value: "The query to field 'Name' is not valid. The $select query string must specify the target fields and the $expand query string must contains Name."
The Name field that I am trying to GET is lookup column (metadata). So one thing that I tried to bypass this is _api/lists/getbytitle('ListName')/items, which pulls everything related to that list through and stores it.
When I look through my response to see what all was returned, along with a million different items and values, this actually does return the Name field (but not how I expected/needed it to be stored). It returns to values related to the one field NameID and NameStringID.
NameID: 49
NameStringID: "49"
I have done research and cannot find any other related topics, I have never worked with metadata in this sense so I am stumped on getting around this issue.
/items?$select=Name/ID&$expand=Nameand this is what it returns in the responseName: {__metadata: {id: "somerandomstringofnumbers", type: "SP.Data.UserInfoItem"}, ID: 9} ID: 9 __metadata: {id: "somerandomstringofnumbers", type: "SP.Data.UserInfoItem"} id: "somerandomstringofnumbers" type: "SP.Data.UserInfoItem"– BeerusDev Mar 09 '21 at 21:00Namecolumn is a Lookup column. The thing you link to here in your first comment is about Managed Metadata columns. And now in your second comment, it appears as though it's actually a User column. Lookup, Managed Metadata and User columns are kind of similar, but really need to be dealt with in different ways. What type of column is yourNamecolumn actually? – Dylan Cristy Mar 09 '21 at 21:06$select=Name/Id,Name/Title&$expand=Name– BeerusDev Mar 09 '21 at 21:08