How does the Search Contact endpoint work?

Hey there,
Having an issue making a seemingly simple request.

var request = require("request");

var options = {
 method: 'POST',
 url: 'https://api.hubapi.com/crm/v3/objects/contacts/search',
 qs: {hapikey: API_KEY},
 headers: {accept: 'application/json', 'content-type': 'application/json'},
 body: {
 filterGroups: [{filters: [{value: '123', propertyName: 'pp_id_parrain', operator: 'EQ'}]}],
 sorts: ['string'],
 query: '123',
 properties: ['firstname'],
 limit: 50,
 after: 50
 },
 json: true
};

request(options, function (error, response, body) {
 if (error) throw new Error(error);

 console.log(body);
});

This is returning:

HTTP 200

{
 "total": 1,
 "results": []
}

I don’t understand why the results aren’t returning a first name. Or results of any kind. I was under the impression the [‘firstname’] in the properties param would mean the firstname of the contact object matching the query would be returned.
Anyone willing to offer some insight?

Hi @nikodev ,

I think you get this response because u are using the after parameter with 50. Change this to 0 and your pagination wil start with the first page.

To access the next page of results, you must pass the after parameter provided in the paging.next.after property of the previous response. If the paging.next.after property isn’t provided, there are no additional results to display. Note: The after parameter is expected to be a string.

Another thing you can try is remove the query options; https://community.hubspot.com/t5/APIs-Integrations/Search-Contact-using-Nodejs-Library-Call/m-p/394400

Regards Ronald