API Get All Deals with Lead Source

SOLVE
ganken
Member

Is there a way for me to get all deals with the lead source property for the deals? The API is returning the lead source when I get a single lead but not in a batch. I tried a few different options but nothing worked. 

 

The below just returns an empty property array. 

https://api.hubapi.com/deals/v1/deal/paged?hapikey= <key> &limit=100&includePropertyVersions=true&properties=lead_source

 

Any help will be much appreciated. 

0 Upvotes
1 Accepted solution

Accepted Solutions
webdew
Solution
Top Contributor | Diamond Partner

Hi @ganken ,

Hope this code work for you :

Api Documentation :
"https://developers.hubspot.com/docs/api/crm/search"

For deal php code fetch result:
<?php
$data = '{
"properties": [ "dealname", "amount", "lead_source" ]
"filterGroups":[
{
"filters":[
{
"propertyName": "<deal_key>",
"operator": "EQ",
"value": "<deal_value>"
}
]
}
]
}';
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.hubapi.com/crm/v3/objects/deals/search?hapikey=YOUR_HUBSPOT_API_KEY');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
?>


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 



View solution in original post

2 Replies 2
dennisedson
Community Manager

@Bryantworks , would you be able to assist here 🙏

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
0 Upvotes
webdew
Solution
Top Contributor | Diamond Partner

Hi @ganken ,

Hope this code work for you :

Api Documentation :
"https://developers.hubspot.com/docs/api/crm/search"

For deal php code fetch result:
<?php
$data = '{
"properties": [ "dealname", "amount", "lead_source" ]
"filterGroups":[
{
"filters":[
{
"propertyName": "<deal_key>",
"operator": "EQ",
"value": "<deal_value>"
}
]
}
]
}';
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.hubapi.com/crm/v3/objects/deals/search?hapikey=YOUR_HUBSPOT_API_KEY');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
?>


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 



View solution in original post