Max Retries Exceeded and Name Resolution Errors When Fetching Deal Information

Hi HubSpot Community,

I’m encountering an issue when trying to fetch deal information via the HubSpot API. My goal is to retrieve details such as deal IDs, deal info, and associated line items. However, after successfully retrieving data for a few deals, I start receiving the following error:

Error: HTTPSConnectionPool(host='api.hubapi.com', port=443): Max retries exceeded with url: /crm/v3/objects/deals/19189399405?properties=hs_object_id&properties=createdate&properties=dealname&properties=dealstage&properties=amount&properties=closedate&properties=dealtype&properties=hs_lastmodifieddate&properties=hubspot_owner_id&properties=hs_created_by_user_id&properties=pipeline&properties=lead_source&properties=hs_mrr&properties=opportunity_type&properties=deal_lost_reason&properties=growth_type&propertiesWithHistory=closedate&propertiesWithHistory=dealstage&propertiesWithHistory=amount&propertiesWithHistory=hs_mrr&associations=companies&archived=False (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x71edd309f990>: Failed to resolve 'api.hubapi.com' ([Errno -3] Temporary failure in name resolution)"))

Hey, @LChauhan1 :waving_hand: Thanks for your post. It looks like there are a few issues with how your request is structured:

  • when using param like `properties`, you only add the param once. Your example has the `properties` param used multiple times
  • for each param, they are comma-separated. You used the ampersand `&`. But you need to use the escaped form of a comma, which is `%2C`
  • you mentioned wanting to return associations for `line_items` but your example has `companies` for the associations param

Here’s an example using your request (I created it using the on-page example here, which is useful for checking how the formatting should look)

curl --request GET \
 --url 'https://api.hubapi.com/crm/v3/objects/deals/00009999?properties=hs_object_id%2Ccreatedate%2Cdealname%2Cdealstage%2Camount%2Cclosedate%2Cdealtype%2Chs_lastmodifieddate%2Chubspot_owner_id%2Chs_created_by_user_id%2Cpipeline%2C%20lead_source%2Chs_mrr%2Copportunity_type%2Cdeal_lost_reason%2C%20growth_type%2C&propertiesWithHistory=closedate%2Cdealstage%2Camount%2Chs_mrr&associations=line_items&archived=false' \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

One way to test is to use the on-page examples and just include 1–2 properties. This saves you time and lets you verify the formatting is valid. I use Postman for most of my testing, but the on-page endpoint examples really shine for use cases like this.

Have fun testing! — Jaycee

Thank you for your suggestion, Jaycee.

In my implementation, I’m utilizing the hubspot-api-client, which automatically constructs the URL for API requests. For example, when fetching deal properties, my code looks like this:

properties = [
“hs_object_id”,
“createdate”,
“dealname”,
“dealstage”,
“amount”,
“closedate”,
“dealtype”,
“hs_lastmodifieddate”,
“hubspot_owner_id”,
“hs_created_by_user_id”,
“pipeline”,
“lead_source”,
“hs_mrr”,
“opportunity_type”,
“deal_lost_reason”,
“growth_type”
]
propertiesWithHistory = [
“closedate”,
“dealstage”,
“amount”,
“hs_mrr”
]

# Fetch the deal properties
deal_response = client.crm.deals.basic_api.get_by_id(
deal_id=dealId,
associations=[“companies”],
archived=False,
properties=properties,
properties_with_history=propertiesWithHistory,
)

Since the client handles the URL construction, there’s no need for manual URL formation in this context

@Jaycee_Lewis can you please have a look at how I am using hubspot-api-client

Hi @LChauhan1

you have not used the properties properly. please go through the documents again to have a better understanding of the same. Sharing you a reference - https://api.hubapi.com/marketing/v3/emails/174096?includeStats=true&marketingCampaignNames=false&workflowNames=false&includedProperties=updatedAt&includedProperties=createdAt&includedProperties=createdById&includedProperties=publishedAt&includedProperties=name&includedProperties=activeDomain&includedProperties=campaign&includedProperties=sentAt&archived=false’

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

@GRajput Thank you for your suggestion, Gaurav

In my implementation, I’m utilizing the hubspot-api-client, which automatically constructs the URL for API requests. For example, when fetching deal properties, my code looks like this:

properties = [
“hs_object_id”,
“createdate”,
“dealname”,
“dealstage”,
“amount”,
“closedate”,
“dealtype”,
“hs_lastmodifieddate”,
“hubspot_owner_id”,
“hs_created_by_user_id”,
“pipeline”,
“lead_source”,
“hs_mrr”,
“opportunity_type”,
“deal_lost_reason”,
“growth_type”
]
propertiesWithHistory = [
“closedate”,
“dealstage”,
“amount”,
“hs_mrr”
]

# Fetch the deal properties
deal_response = client.crm.deals.basic_api.get_by_id(
deal_id=dealId,
associations=[“companies”],
archived=False,
properties=properties,
properties_with_history=propertiesWithHistory,
)

Since the client handles the URL construction, there’s no need for manual URL formation in this context