APIs & Integrations

SN0
Member

How to send filter in http post req

I'm trying to fetch the updated companies after a particular time. I tried the search query with filter in the body. It throws 400 error. Could you advice me in this regard?

 

Corelation id : 3450d60c-25c8-49d4-995b-3126b926b575

 

String url = "https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=xxxxxxxx";

 

HttpPost method = new HttpPost();

 

method.setURI(new URI(url));

 

method.addHeader("Content-Type", "application/json");

    StringEntity stringEntity = new StringEntity("{ \"filterGroups\":[ { \"filters\":[ { \"propertyName\": \"createdAt\", \"operator\": \"GTE\", \"value\": \"2020-12-15T17:52:40.614Z\" } ] } ] }");

    method.setEntity(stringEntity);

 

    HttpClient client  = HttpClientBuilder.create().build();

 

HttpResponse response = client.execute(method);

System.out.println(response.getStatusLine().getStatusCode());

StringWriter w = new StringWriter();

IOUtils.copy(response.getEntity().getContent(), w, Charset.defaultCharset());

System.out.println(w.toString());

0 Upvotes
2 Replies 2
SN0
Member

How to send filter in http post req

https://developers.hubspot.com/docs/api/crm/search

 

I checked this doc and found that createdAt field is not supported in filter.  How can I fetch the records which are updated after a particular time?

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

How to send filter in http post req

Hi @SN0 

Wonder if @quentin_lamamy  or @lynton  might have some work around

0 Upvotes