How to use request parameters in query string to retrieve JobNimbus contacts

Viewed 41

I am trying to fetch a contact in JobNimbus based on their display name. According to their docs under "Retrieve All Contacts", I should be able to do this.

Below is the code they recommend:

var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://app.jobnimbus.com/api1/contacts',
  headers: { 
    'Authorization': 'bearer <token>', 
    'Content-Type': 'application/json'
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

Below is their request parameters example:

{
    "must": [
        {
            "range": {
                "date_created": {
                    "gte": 1459749600,
                    "lte": 1459835940
                }
            }
        }
    ]
}

How do I request a contact based on their display_name?

1 Answers

It explains how to filter your search in the docs here. Just have to include the search criteria in the query params.

var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://app.jobnimbus.com/api1/contacts?filter={"must":[{"term":{"first_name":"John"}},{"term":{"last_name":"Smith"}}]}
',
  headers: { 
    'Authorization': 'bearer <token>', 
    'Content-Type': 'application/json'
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
Related