HubSpot API

Hi, I'm completely new to writing API requests and I'm trying to write the following request:

I want to get all closed deals from Hubspot over the current fiscal year (which runs April to Mar) so I can build a revenue klip. I've written the following API, but think I might have made mistake with the end of year part.

https://api.hubapi.com/deals/v1/deal/closed?start-date={date.firstMOY("apr").startOfYear.format()}&end-date={date.last MOY("mar").endOfYear.format()}

I receive the following error message when trying to create the query.

We couldn't retrieve the data you requested. Check your account permissions and connection and try again.

Any help would be greatly appreciated.


  • Avatar
    Parker Selman Official comment

    Hi Corey, 

    Thanks for the post! 

    In this case, you'll actually want to use the Hubspot search API  as this will allow for you to query for only those deals that have a closedate within the range given. Additionally, there's a bit of tweaking required to get this working given Hubspot's date format requirements. Overall, the request as set up below will return deals with a closedate within your fiscal year:

    I hope this helps! 


  • 0
    Corey Benefiel

    Thanks Parker,


    That is super helpful. I appreciate it.

    Unfortunately, it didn't work for me, and I received the same error message. I set up a fresh connection for this and I'm a SuperAdmin in our Hubspot account, so I'm not sure what's preventing this from working.



  • 0
    Parker Selman

    Hi Corey, 

    Thanks for the follow-up. In this case, it looks like there's an extra 0 in your first date term, under 'highvalue', which should actually be listed as "highValue" with a capital V. 

    Specifically though, the extra zero is within the format brackets as ("unixtime"0) 

    Removing that and changing to a capital V should resolve the issue. If you continue to face trouble around this, I'd recommend emailing support@klipfolio.com to create a support ticket where we can work closely with your account to troubleshoot this connection. 



Please sign in to leave a comment.