<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Deals API 'hasMore' response (getting all deals) in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Deals-API-hasMore-response-getting-all-deals/m-p/259158#M23120</link>
    <description>&lt;P&gt;Hi adimoglis!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've figured out the issue. In your code,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;parameter_dict[Offset]&lt;/PRE&gt;
&lt;P&gt;needs to be:&lt;/P&gt;
&lt;PRE&gt;parameter_dict[offset]&lt;/PRE&gt;
&lt;P&gt; (lowercase o)&lt;/P&gt; 
&lt;P&gt; This is a documentation error on my part, that I will now correct. Thank you for bringing it to my attention! &lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2019 17:46:09 GMT</pubDate>
    <dc:creator>LeifInouye</dc:creator>
    <dc:date>2019-03-14T17:46:09Z</dc:date>
    <item>
      <title>Deals API 'hasMore' response (getting all deals)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Deals-API-hasMore-response-getting-all-deals/m-p/258739#M23076</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;In &lt;A href="https://developers.hubspot.com/docs/methods/deals/get-all-deals" target="_self"&gt;API Documentation&lt;/A&gt;, I see that there are two 'variebles' in the response:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;hasMore&lt;/LI&gt;&lt;LI&gt;Offset&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In the deault code provided by the documentation, I removed the 'max_results' condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    import requests
    import json
    import urllib

    #max_results = 500
    hapikey = 'demo'
    limit = 250
    deal_list = []
    get_all_deals_url = "https://api.hubapi.com/deals/v1/deal/paged?"
    parameter_dict = {'hapikey': hapikey, 'limit': limit}
    headers = {}

    # Paginate your request using offset
    has_more = True
    while has_more:
        parameters = urllib.parse.urlencode(parameter_dict)
        get_url = get_all_deals_url + parameters
        r = requests.get(url= get_url, headers = headers)
        response_dict = json.loads(r.text)
        has_more = response_dict['hasMore']
        deal_list.extend(response_dict['deals'])
        parameter_dict['Offset']= response_dict['offset']
        print(response_dict['offset'])
        print(response_dict['hasMore'])


    print('loop finished')

    list_length = len(deal_list)

    print("You've succesfully parsed through {} deal records and added them to a list".format(list_length))&lt;/PRE&gt;&lt;P&gt;So, I expect the script to finish when 'has_more' attribute is False. But this will never happen, neither in the demo, nor in our company deals.&lt;/P&gt;&lt;P&gt;The API answers 'True' and the same 'Offset' for all iterations.&lt;BR /&gt;&lt;BR /&gt;Is this the default behaviour?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 10:09:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Deals-API-hasMore-response-getting-all-deals/m-p/258739#M23076</guid>
      <dc:creator>adimoglis</dc:creator>
      <dc:date>2019-03-13T10:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Deals API 'hasMore' response (getting all deals)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Deals-API-hasMore-response-getting-all-deals/m-p/259115#M23112</link>
      <description>&lt;P&gt;Hi adimoglis,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Interesting-- the intended behavior of that script is to operate even when a `max-results` is omitted. Let me look into this -- I will reach back out shortly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 15:47:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Deals-API-hasMore-response-getting-all-deals/m-p/259115#M23112</guid>
      <dc:creator>LeifInouye</dc:creator>
      <dc:date>2019-03-14T15:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Deals API 'hasMore' response (getting all deals)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Deals-API-hasMore-response-getting-all-deals/m-p/259158#M23120</link>
      <description>&lt;P&gt;Hi adimoglis!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've figured out the issue. In your code,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;parameter_dict[Offset]&lt;/PRE&gt;
&lt;P&gt;needs to be:&lt;/P&gt;
&lt;PRE&gt;parameter_dict[offset]&lt;/PRE&gt;
&lt;P&gt; (lowercase o)&lt;/P&gt; 
&lt;P&gt; This is a documentation error on my part, that I will now correct. Thank you for bringing it to my attention! &lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 17:46:09 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Deals-API-hasMore-response-getting-all-deals/m-p/259158#M23120</guid>
      <dc:creator>LeifInouye</dc:creator>
      <dc:date>2019-03-14T17:46:09Z</dc:date>
    </item>
  </channel>
</rss>

