Forum Discussion
SharePoint 2016 REST API: query filtered by ContentType
- JaredMatfessIron Contributor
Hi Gina,
So I think you'll need to modify your REST query just a bit..
In order to get the ContentType name you'll need to select it with $select=ContentType/Name&$expand=ContentType to get at the actual name value
Here's a working query that I have on a Library with Documents & Link to Document Content Types. I'm filtering to give me just the items that are Link to Document:
/_api/web/lists/getbytitle('DynProdFiles')/items?$select=Title,URL,ContentType/Name&$expand=ContentType&$filter=ContentType eq 'Link to a Document'
Good luck, let me know if that helps!
-Jared
- Radosław SzymczakCopper Contributor
Hi Jared,
It does not work in SharePoint 2016. You get the same error - column 'ContentType' does not exists, even if you expand one.
- JaredMatfessIron Contributor
Gina Bolognesi just following up if my previous post was helpful?
- Jyothi GatupaCopper Contributor
Jared, I am running into the same issue as Gina did and I tried your suggestion. It did NOT work. Adding the filter to the query breaks it in SharePoint 2016
$filter=ContentType eq 'VideoContentType'
Do you have any suggestions? OR please let me know if someone else encountered this?
- Jyothi GatupaCopper Contributor
This is how my query looks like
/_api/Web/Lists/GetByTitle('Portal%20Content%20Library')/items?$select=ContentType/Name&$expand=ContentType&$filter=ContentType eq 'VideoContentType'
- prasad yelpulaCopper Contributor
Hi Gina,
Have you found any solution for this issue?. Because, I am also facing same issue in my SP2016 migration server.
Kindly let me know if you have found any solution.
Thanks in adv.
- CamSibbaldCopper Contributor
This has been fixed somewhere along the line by a cumulative update.
I noticed the issue on a SP2016 VM that had only been patched to FP2. Installing the most recent CU fixed the issue for me.
- prasad yelpulaCopper Contributor
Thanks Cameron.
Issue has been fixed after installing CU. In MS updates blog also its mentioned.
Ref. below link ( Improvements and fixes section) : Improvements and fixes