Get all deals API returning incorrect offset

Highlighted
Occasional Contributor

There is an issue where the offset param in the get all deals are returning the same offset value And do so - this gets us stuck in an infinite loop where we never get the next page of results.

 Here is the endpoint url: 'https://app.hubspot.com/deals/v1/deal/paged?hapikey={Signature}&includeAssociations=true&limit=200&Offset={vidOffset}&properties=dealname'

its returning same offset value: 524562026 which causing infinite loop and not getting all the deals.

7 Replies 7
Regular Contributor

Hi there,

 

Is the returned 'hasMore' holding the value of 'true' in the returned response? I've just tried grabbing my own deals - https://developers.hubspot.com/docs/methods/deals/get-all-deals, in my own portal and did not run into such an issue.

Reply
0 Upvotes
Occasional Contributor

Yes, it returns 'hasMore' value of 'true' in response.which is causing infinite loop

Reply
0 Upvotes
Regular Contributor

Well that's strange. I'm unsure how this could happen but I think if you shared more of what you've implemented, it could potentially allow someone here to assist further. Smiley Happy

Reply
0 Upvotes
Occasional Contributor

we have around 300+ records, we set the initial value of offset to 0, in the first iteration it's returning  200 deals with offset value 524562026 and 'hasMore' value of 'true'. and from next iteration, it's giving same deals, offset value and 'hasMore' value of 'true'.

 

Request:

 

var hasMore = true;
long vidOffset = 0;

while (hasMore)
{
var strUrl = $"https://app.hubspot.com/deals/v1/deal/paged?hapikey={Signature}&includeAssociations=true&limit=200&O...";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strUrl);
req.Method = "GET";
req.ContentType = "application/json";
using (var resp = (HttpWebResponse)req.GetResponse())
{
using (var sr = new StreamReader(resp.GetResponseStream()))
{
searchResult = sr.ReadToEnd();
}
}
var jr = JsonReader.ParseObject(searchResult);
var arr = (JsonArray)jr["deals"];
vidOffset = Convert.ToInt32(jr["offset"].ToString());
hasMore = Convert.ToBoolean(jr["hasMore"].ToString());
}

Response: 

 

1st iteration

 

deals: [200]

hasMore: true

offset: 524562026

 

2nd iteration. and so on

deals: [200] 

hasMore: true

offset: 524562026

 

Reply
0 Upvotes
Occasional Contributor

we have 300+ records in deals and set the limit to 200 per batch and the default offset value is zero. in first batch API return 200 records, hasMore value is true and offset is 524562026, in second iteration by passing offset value = 524562026, its returning same records with a same offset value and hasMore value true. which leads to stuck in an infinite loop where we never get the next batch of results.

 

Request:

var hasMore = true;
long vidOffset = 0;

while (hasMore)
{
var strUrl = $"https://app.hubspot.com/deals/v1/deal/paged?hapikey=HAPIKEY&includeAssociations=true&limit=200&Offset={vidOffset}&properties=dealname";

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strUrl);
req.Method = "GET";
req.ContentType = "application/json";
using (var resp = (HttpWebResponse)req.GetResponse())
{
using (var sr = new StreamReader(resp.GetResponseStream()))
{
searchResult = sr.ReadToEnd();
}
}
var jr = JsonReader.ParseObject(searchResult);
var arr = (JsonArray)jr["deals"];
vidOffset = Convert.ToInt32(jr["offset"].ToString());
hasMore = Convert.ToBoolean(jr["hasMore"].ToString());
}

 

Response:

 

first iteration

deals:[200]-records

hasMore: true

offset: 524562026

 

second iteration

deals:[200]--same records

hasMore: true

offset: 524562026

 

 and so on......

 

Note: we are facing the same issue for Get all companies API

Reply
0 Upvotes
Occasional Contributor

Hello,

Any update on this ticket..?

Reply
0 Upvotes
Visitor

Is there any update on this issue? I am facing the same issue for https://developers.hubspot.com/docs/methods/lists/get_lists API.

 

I am getting has-more true in response but offset is not updating. Though I am passing lastest update in API params.

Reply
0 Upvotes