I can't for the life of me figure out what's wrong with this URL:

_spPageContextInfo.webAbsoluteUrl + String.format("/_api/web/lists/getbytitle('{0}')/items?$select=ContentType/Name&$expand=ContentType&$filter=ContentType/Name eq 'Highlight Report'", documentsListTitle)

I get

400 (Bad Request)

Note I'm specifically looking for a REST solution with an example if possible.

  • getbytitle('{0}') ? I thought there should be the listname...
    – Patrick
    Commented Nov 25, 2015 at 15:46
  • Notice the use of String.format.
    – Submits
    Commented Nov 25, 2015 at 15:47
  • To the close voters: The question is regarding REST API not server side or client side using C#. Hope you understand. Commented Nov 26, 2015 at 9:58

3 Answers 3


Found a way which works for me. SharePoint 2013 on-prem.

Starting point:

A document library with two content types Document & Highlight Report and two documents in it for testing purpose.

enter image description here


The REST URL for filtering only the document with the content type Document is:

https://<yourdomain>/_api/lists/getbytitle('<yourlistname>')/items?$filter=ContentType eq 'Document'

The output is:

enter image description here

If you want to get the document lorem1 which is content type Highlight Report the REST URL looks like this:

https://<yourdomain>/_api/lists/getbytitle('<yourlistname>')/items?$filter=ContentType eq 'Highlight Report'

enter image description here

Hope this could help you.

  • Just tried this and I get back a zero length array, which probably means no items were returned, which means the filter isn't working (I should get two items).
    – Submits
    Commented Nov 26, 2015 at 9:23
  • What is the name of the library and of the content type? Could you try to get first all your items with /_api/web/lists/getbytitle('LIBRARYNAME')/items
    – Patrick
    Commented Nov 26, 2015 at 9:27
  • Yes using that URL /_api/web/lists/getbytitle('Documents')/items I get back all the items from the list. But when I add ?$filter=startswith(ContentType,'Highlight Report') I get back nothing.
    – Submits
    Commented Nov 26, 2015 at 9:46
  • 1
    Filtering on content type name also works for me without the use of CAML. Check my updated answer.
    – HarryB
    Commented Nov 26, 2015 at 10:52
  • 1
    Updated the answer with english pictures and the content type you are using.
    – Patrick
    Commented Nov 26, 2015 at 11:05

$filter by ContentType is not supported. Reason could be ContentType is not any column of list OR Microsoft does not support it yet. $expand is supported.

Ignore the &$filter=ContentType/Name eq 'Highlight Report'" and see it works.

Update #1:

Following solution is regarding CAML + C#

Filter By ContentType using CAML

Now make it CAML + REST API

        <FieldRef Name='ContentType'/>
        <Value Type='Computed'>Highlight Report</Value>

For executing CAML in REST API


String.format("/_api/web/lists/getbytitle('{0}')/getitems", documentsListTitle)

HTTP Method:


Request Body:

var query = "<View>" + 
 "<Query>" + 
 "<Where>" + 
 "<Eq>" + 
 "<FieldRef Name='ContentType'/>" + 
 "<Value Type='Computed'>Highlight Report</Value>" + 
 "</Eq>" + 
 "</Where>" + 
 "</Query>" + 

var data = {
    query: {
        __metadata: {
            'type': 'SP.CamlQuery'
        ViewXml: query

Let me know for more modification or explanation.

  • Yep, it works without the filter but then how do I filter by the name of a content type? Surely there's a way
    – Submits
    Commented Nov 25, 2015 at 15:59
  • did not find any using REST yet. there could way using CSOM. If you are dealing with very few items, then filter them in request complete like success function Commented Nov 25, 2015 at 16:04
  • See my last update @Submits Commented Nov 26, 2015 at 5:53
  • ok ...... waiting to hear from you Commented Nov 26, 2015 at 9:22
  • Brilliant, it worked. It's a shame you have to use CAML to achieve this though! Thanks.
    – Submits
    Commented Nov 26, 2015 at 10:14

Try using ContentTypeId as the filter , the example below is returning results for me:


Update 1: Filtering on ContentType field also works. Try by replacing the space within the content type name by %20 in your REST Url

  • ContentTypeId is not an option because this site will become a site template and I'm not sure the content type IDs will remain the same.
    – Submits
    Commented Nov 25, 2015 at 17:49
  • You can get the content type Id dynamically by making a request like this: /_api/web/ContentTypes?$select=Name,Id&$filter=Name%20eq%20%27Item%27
    – HarryB
    Commented Nov 25, 2015 at 17:56
  • You're right, this could be a solution. The only down side is I would need to make two REST calls.
    – Submits
    Commented Nov 26, 2015 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.