# Search Contact using Nodejs Library Call

**URL:** <https://community.hubspot.com/t/search-contact-using-nodejs-library-call/29298>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, oauth, free, contacts\
**Created:** [December 17, 2020, 3:06am UTC](https://community.hubspot.com/t/search-contact-using-nodejs-library-call/29298 "2020-12-17T03:06:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PCarlson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pcarlson/32/35493_2.png) [@PCarlson](https://community.hubspot.com/u/PCarlson)\
**Post date:** [December 17, 2020, 3:06am UTC](https://community.hubspot.com/t/search-contact-using-nodejs-library-call/29298/1 "2020-12-17T03:06:30Z")

</div>

I’m new to the API and using a modified version of the quickstart app from GitHub. I’m trying to find a contact by his email address and no matter what I try I get:

`{"total":0,"results":[]}`

I simplified it to search for a literal firstname and still no results. I see other people successfully searching, but all the answers are using curl rather than the library and using the API key rather than OAuth. I have OAuth working to get a token. I also have separately used curl with a v1 endpoint to successfully find a contact. But no luck with Nodejs api library and OAuth.

Here is my function doing the search:

```lia-code-sample
const getContactByEmail = async (accessToken, email_address) => {
 console.log('');
 console.log('=== Retrieving a contact by email from HubSpot using the access token ===');

 const filter = { propertyName: 'firstname', operator: 'EQ', value: 'Brian' }
 const filterGroup = { filters: [filter] }
 const sort = 'firstname'
 const query = 'test'
 const properties = ['company', 'email', 'firstname', 'lastname']
 const limit = 100
 const after = 0

 const publicObjectSearchRequest = {
 filterGroups: [filterGroup],
 sorts: [sort],
 query,
 properties,
 limit,
 after
 };

 console.log(publicObjectSearchRequest)
 console.log(publicObjectSearchRequest.filterGroups[0].filters[0])
 const result = await hubspotClient.crm.contacts.searchApi.doSearch(publicObjectSearchRequest)
 console.log(JSON.stringify(result.body))
 return result.body
}

```

And here is the console output:

```lia-code-sample
=== Retrieving a contact by email from HubSpot using the access token ===
{
 filterGroups: [{ filters: [Array] } ],
 sorts: ['firstname'],
 query: 'test',
 properties: ['company', 'email', 'firstname', 'lastname'],
 limit: 100,
 after: 0
}
{ propertyName: 'firstname', operator: 'EQ', value: 'Brian' }
{"total":0,"results":[]}

```

I tried the email\_address parameter first. I also tried LTE and CONTAINS\_TOKEN and other attempts all with the same result.

Please let me know what I’m missing.

Thanks

Phil

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [December 17, 2020, 11:59am UTC](https://community.hubspot.com/t/search-contact-using-nodejs-library-call/29298/2 "2020-12-17T11:59:11Z")

</div>

I’m using the same api call, with only the filterGroup set.  
This is working perfect!  
If you remove the

sorts, query, properties, limit, after

From your publicObjectSearchRequest, is the call then working?

---

<div class="post-metadata">

**Author:** ![PCarlson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pcarlson/32/35493_2.png) [@PCarlson](https://community.hubspot.com/u/PCarlson)\
**Post date:** [December 18, 2020, 1:56am UTC](https://community.hubspot.com/t/search-contact-using-nodejs-library-call/29298/3 "2020-12-18T01:56:47Z")

</div>

Thanks RMones, that worked! I gave you an upvote and I’ll accept your post as solution.

Any additional info on why I cannot have the other options and why it does not work with all options (I took this straight from the GitHub sample and only modified the filter)?

I’ll experiment and see which breaks it, but any tips on what’s going on, what combinations work and what doesn’t work are very welcome!

---

<div class="post-metadata">

**Author:** ![PCarlson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pcarlson/32/35493_2.png) [@PCarlson](https://community.hubspot.com/u/PCarlson)\
**Post date:** [December 18, 2020, 2:26am UTC](https://community.hubspot.com/t/search-contact-using-nodejs-library-call/29298/4 "2020-12-18T02:26:37Z")

</div>

The offending line was

`const query = 'test'`

Removing from publicObjectSearchRequest only the single line like:

`query,`

made the error go away, but it did not list the properties I requested, so I’ll have to play some more.

FYI, that line was exactly taken from the README.md under “{EXAMPLE} Search Contacts:” at [GitHub - HubSpot/hubspot-api-nodejs: HubSpot API NodeJS Client Libraries for V3 version of the API · GitHub](https://github.com/HubSpot/hubspot-api-nodejs) so it would be nice to fix that so that example works.

Phil
