How to export data from HubSpot using a filter (via API) error using Postman

Hi,

I am looking to import events from HubSpot into our company software via an API.

We need to know how to use the API within HubSpot to export all the contacts who has an activity within the last week and have them imported into our company software.

I tried with the tool “postman” and received an error

POST https://api.hubspot.com/crm/v3/objects/contacts/exports

HEADER

“Content-Type”: “application/json”
“Authorization” : "Bearer " + APITOKEN

BODY

{

“objects”: [“contacts”],

“filters”: [

{

“value”: “7”,

“propertyName”: “lastActivityDate”,

“operator”: “GTE”

}

],

“nextPageToken”: null

}

the result is :

<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html;charset=utf-8”/>
<title>Error 405 Method Not Allowed</title>
</head>
<body><h2>HTTP ERROR 405</h2>
<p>Reason:
<pre> Method Not Allowed</pre></p>
</body>
</html>

Perhaps I am doing something wrong?

Hi @SHosdaghian,

To create an export you’ll want to use the “/crm/v3/exports/export/async” method which starts an export with the specified fitlers, you can find information about that here.

As an alternative you could use the search api which you can find information about here. Which for this example you would be posting to the url " /crm/v3/objects/contacts/search".

Best,

Hello @SHosdaghian , You can use that curl to test it directly in the POSTMAN , using your token

curl --location ‘https://api.hubspot.com/crm/v3/exports/export/async’ \
--header ‘Content-Type: application/json’ \
--header ‘Authorization: Bearer <your_token_here>’ \
--data ’
{
“exportType”: “VIEW”,
“exportName”: “All contacts”,
“format”: “xlsx”,
“language”: “DE”,
“objectType”: “CONTACTS”,
“objectProperties”: [
“lastActivityDate”
],
“publicCrmSearchRequest”: {
“filters”: [
{
“value”: “7”,
“propertyName”: “lastActivityDate”,
“operator”: “GTE”
}
],
“query”: “hello”,
“sorts”: [
{
“propertyName”: “email”,
“order”: “ASC”
}
]
}
}’

It will give you the document export progress link in response and you can check status by that .

for ref you can checl =Accounts Dashboard | HubSpot).