Retrieving the Content Type in a REST Call in SharePoint 2013 On Premises

Content Type

I’m working in a SharePoint 2013 on premises installation, and I needed to get the ContentType back from a REST call. Content Type is often the most important piece of metadata in a list or library, with the detailed metadata for the Content Type coming in as secondary. It certainly matters which Content Type you have if you’re building custom UIs like I am.

On SharePoint Online, this works:

/_api/web/lists/getbytitle('MyList')/items?
$select=ContentType/Name&$expand=ContentType

But on premises, it doesn’t. Nothing comes back for the ContentType at all.

I found this great little tip from eko buried in a StackExchange comment – with no up votes. Up votes matter, people, so make sure you use them.

Simply add ContentTypeId to the $select and you’re in business:

/_api/web/lists/getbytitle('MyList')/items?
$select=ContentTypeId,ContentType/Name&$expand=ContentType

We shouldn’t need to do this sort of workaround, but it’s great when we can!

Similar Posts

3 Comments

  1. I dont think it is possible to use “ContentType/Name” as a filter in the oData. Is there any work around to use that as part of the filter?. I am talking about on-prem.

Leave a Reply to SANDEEP PULLURU Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.