There is an issue where theoffsetparam in the get all deals are returning the sameoffsetvalue 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.
Jan 29, 202010:32 AM - edited Jan 29, 202010:37 AM
Participant
Get all deals API returning incorrect offset
1) It might be because 'offset' is string (alphanumeric) and not integer. So, you are effectively converting that string to 0. 🙂 Use it without converting to integer.
2) You are trying to use 'Offset' field in the request. And it should be lowercase: 'offset'.
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. 🙂
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.
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()); }