Hubspot - How to filter for today's date?

Hello Community,

I need to get Contacts data from Hubspot and I need to get them once a day.
I care only about Contacts with a Created Date in HS matching Today, so the day of the scenario execution.

Is my approach correct or should I just compare Unix timestamps with Greater than and Lesser than or equal?
I am using a Watch CRM Objects trigger, that runs Once a day and it is set to get data From now on.

Current state of the trigger, it gives me 400 error from HS when run and using timestamp will give me similar results, I guess I need to format Make.com dates to the format recognised by HS.

Thanks in advance!

Welcome to the Make community!

According to the Tokens you can use to format a date variable, you can use x to get time in millis.

Then, because formatDate returns a variable of type string, you’ll need to use parseNumber to convert it into a variable of type number.

Input bundle

2 Likes

Great info, thank you, but it seems to give me 400 still, any setting that I am missing? When I inspect the request it seems like it sends a raw string instead of a computed value?

You’ll want to use a small “x”, not a capital “X”.

2 Likes

Thought about it and have already checked both options, still gives me the same error, is there any formatting mistake on my side I cannot see?

when using small x for both fields, the result is still an error.

Can’t you just use:

image

If you execute the scenario once every 24 hours, this should get you everything that’s been created since then.

1 Like

Great point but I still don’t know why my requests gets sent without a value, but with a raw string of my ‘formula’ on the filters array.
How does it look on your side?


{
    "_engineData": {
        "calledAt": "Not available"
    },
    "response": {
        "status": 400,
        "headers": {
            "date": "Mon, 27 Nov 2023 17:29:59 GMT",
            "content-type": "application/json;charset=utf-8",
            "content-length": "123",
            "connection": "close",
            "cf-ray": "82cc18afed169597-DUB",
            "cf-cache-status": "DYNAMIC",
            "strict-transport-security": "max-age=31536000; includeSubDomains; preload",
            "vary": "origin",
            "access-control-allow-credentials": "false",
            "x-content-type-options": "nosniff",
            "x-envoy-upstream-service-time": "96",
            "x-evy-trace-listener": "listener_https",
            "x-evy-trace-route-configuration": "listener_https/all",
            "x-evy-trace-route-service-name": "envoyset-translator",
            "x-evy-trace-served-by-pod": "iad02/hubapi-td/envoy-proxy-66c9b4c4f4-d2k8j",
            "x-evy-trace-virtual-host": "all",
            "x-hubspot-correlation-id": "e2335f9c-5729-4658-a81b-c361c8b5409e",
            "x-request-id": "e2335f9c-5729-4658-a81b-c361c8b5409e",
            "x-trace": "2B0B54F8A95F70CC693C837FA06E3E1DF8C3F2D1D9000000000000000000",
            "report-to": "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=wO49CezH7FLPLhcixHxlthyjrF8BB3AYmjih7h6N%2F9nkpcXgbZGTfZpNU%2BtRSv87csvfeJwo6ZdcMuScZWN5tBBxZvgDmADQZlom06XjppiW7CMbRN%2Fx2DlrfjFJ4yAK\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
            "nel": "{\"success_fraction\":0.01,\"report_to\":\"cf-nel\",\"max_age\":604800}",
            "server": "cloudflare"
        },
        "body": {
            "status": "error",
            "message": "There was a problem with the request.",
            "correlationId": "e2335f9c-5729-4658-a81b-c361c8b5409e"
        },
        "_engineData": {
            "calledAt": "Not available"
        }
    },
    "request": {
        "url": "https://api.hubapi.com/crm/v3/objects/contacts/search",
        "headers": {
            "user-agent": "Make/production",
            "authorization": "***",
            "content-type": "application/json"
        },
        "method": "POST",
        "body": {
            "limit": 100,
            "sorts": [
                {
                    "direction": "DESCENDING",
                    "propertyName": "createdate"
                }
            ],
            "properties": [],
            "filterGroups": [
                {
                    "filters": [
                        {
                            "propertyName": "createdate",
                            "operator": "GT",
                            "value": "{{addHours(now; -24)}}"
                        }
                    ]
                }
            ]
        }
    }
}

This is normal actually. You’re inspecting the underlying input bundle which will be transformed by Make before making the request.

This is how the input bundle looks like after that transformation:

You need to switch to the response headers/body tabs just above that section to see what’s returned by HubSpot.

2 Likes

I am not sure about that, Make.com logs the direct request body to dev console as well and I see a String there, but computed values for all other fields, I cannot figure out what am I doing wrong sadly.
this is a filters array that I guess is sent, with a request, still a string, not the value produced by a formula.

[
    {
        "propertyName": "createdate",
        "operator": "GT",
        "value": "{{addHours(now; -24)}}"
    }
]

I cannot see the bundle as I get 400 error as HS api expects a unix timestamp and Im sending a string.
Could you please make screenshots of your setup and how it works for you? Thank you.

Hello @Tyburek_Dawid :wave:

I noticed that you’ve opened a ticket with us, and our support team has investigated the matter and provided you with the following advice :arrow_down:


Make Support response:

To select a point in time from which you want to process your data, right-click on the trigger module and click “choose where to start”.




This gives you the option to process all of your data, to process it from now on, or since a specific date. In your case, you would select “from now on”.

You can then schedule the scenario to run once a day, and it will return all the companies created since the last run.

image

2 Likes