# REST Query Collection Based on Custom Field

**URL:** <https://discourse.getcockpit.com/t/rest-query-collection-based-on-custom-field/1044>\
**Category:** Support\
**Created:** [October 3, 2019, 3:37pm UTC](https://discourse.getcockpit.com/t/rest-query-collection-based-on-custom-field/1044 "2019-10-03T15:37:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zennlee](https://avatars.discourse-cdn.com/v4/letter/z/48db29/32.png) [@zennlee](https://discourse.getcockpit.com/u/zennlee)\
**Post date:** [October 3, 2019, 3:37pm UTC](https://discourse.getcockpit.com/t/rest-query-collection-based-on-custom-field/1044/1 "2019-10-03T15:37:56Z")

</div>

I imagine this should be a simple question but I cannot find an answer.

I am trying to query using the REST API for one **article** with my custom field **id** of **THIS\_IS\_IT** ;

The issue is I receive an array of every article no matter how I configure the filter object. What am I doing wrong?

```auto
const options = {
   url: `${config.cms.endpoint}collections/get/articles?token=${config.cms.apiKey}`,
   method: 'POST',
   encoding: 'utf-8',
   body: JSON.stringify({
     filter: { published: true, id: 'THIS_IS_IT' },
     sort: { _created: -1 },
   }),
   resolveWithFullResponse: false,
 };

 const articles = await request(options);

```

Thank you so much!

---

<div class="post-metadata">

**Author:** ![ronaldaug](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/ronaldaug/32/260_2.png) [@ronaldaug](https://discourse.getcockpit.com/u/ronaldaug)\
**Post date:** [October 7, 2019, 5:31am UTC](https://discourse.getcockpit.com/t/rest-query-collection-based-on-custom-field/1044/3 "2019-10-07T05:31:47Z")

</div>

I guess If you’re using **JSON.stringify** , you should add `"Content-type: application/json"` . Otherwise, it will use a default `"application/x-www-form-urlencoded"`

As I understand, you’re filtering by ID and it will return a specific entry. So, `sort` isn’t necessary here.

You can also try this below option

```javascript

${config.cms.endpoint}collections/get/articles?filter[published]=true&filter[id]=THIS_IS_IT&token=${config.cms.apiKey}

```
