# Looping Through companies API, I randomly get an error part way through.

**URL:** <https://community.hubspot.com/t/looping-through-companies-api-i-randomly-get-an-error-part-way-through/12883>\
**Category:** APIs & Integrations\
**Tags:** companies\
**Created:** [February 8, 2019, 9:19pm UTC](https://community.hubspot.com/t/looping-through-companies-api-i-randomly-get-an-error-part-way-through/12883 "2019-02-08T21:19:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveka](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/steveka/32/63860_2.png) [@steveka](https://community.hubspot.com/u/steveka)\
**Post date:** [February 8, 2019, 9:19pm UTC](https://community.hubspot.com/t/looping-through-companies-api-i-randomly-get-an-error-part-way-through/12883/1 "2019-02-08T21:19:33Z")

</div>

Hi There,

I’m looping through the companies paged api with php and curl, and seem to randomly get an error sometimes. Maybe the first or 5th iteration, seems random. Any help would be appreciated…

The error is

{“status”:“error”,“message”:“internal error”,“correlationId”:“c5ae9498-ab7b-4e38-9764-fbc5fda04dd2”,“requestId”:“871ce6be5271bcc16bd3cfde5540159f”}

Request was this, works in postman. The x’s are placeholder

[https://api.hubapi.com/companies/v2/companies/paged?hapikey=xxxxxxx&properties=name&properties=acct\_status&properties=card\_type&properties=card\_system&properties=contracting\_co&properties=account\_notes&properties=account\_type&properties=hubspot\_owner\_id&properties=billing\_cycle&properties=ar\_code&properties=terms\_code&properties=address&properties=city&properties=state&properties=zip&properties=contracting\_co\_market&properties=gm\_account\_&properties=website&properties=record\_type&properties=gm\_source&properties=ic&properties=mcp\_&properties=competitor&properties=business\_type&properties=last\_activity\_date\_gm&properties=hs\_lead\_status&properties=account\_number&properties=credit\_line&properties=hs\_lastmodifieddate&properties=invoice\_delivery&properties=termsync\_export&properties=fax&properties=statement\_delivery&properties=billing\_address\_1&properties=billing\_address\_2&properties=billing\_city&properties=billing\_state&properties=billing\_zip&limit=100&offset=xxxxx](https://api.hubapi.com/companies/v2/companies/paged?hapikey=xxxxxxx&properties=name&properties=acct_status&properties=card_type&properties=card_system&properties=contracting_co&properties=account_notes&properties=account_type&properties=hubspot_owner_id&properties=billing_cycle&properties=ar_code&properties=terms_code&properties=address&properties=city&properties=state&properties=zip&properties=contracting_co_market&properties=gm_account_&properties=website&properties=record_type&properties=gm_source&properties=ic&properties=mcp_&properties=competitor&properties=business_type&properties=last_activity_date_gm&properties=hs_lead_status&properties=account_number&properties=credit_line&properties=hs_lastmodifieddate&properties=invoice_delivery&properties=termsync_export&properties=fax&properties=statement_delivery&properties=billing_address_1&properties=billing_address_2&properties=billing_city&properties=billing_state&properties=billing_zip&limit=100&offset=xxxxx)

---

<div class="post-metadata">

**Author:** ![hot\_z](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/hot_z/32/86357_2.png) [@hot\_z](https://community.hubspot.com/u/hot_z)\
**Post date:** [February 11, 2019, 7:54am UTC](https://community.hubspot.com/t/looping-through-companies-api-i-randomly-get-an-error-part-way-through/12883/2 "2019-02-11T07:54:02Z")

</div>

Hi there,

I think that there is a possibility that your issue is related to what happened in [https://community.hubspot.com/t5/APIs-Integrations/Get-all-companies-throws-random-HTTP-500-errors/m-p/251587](https://community.hubspot.com/t5/APIs-Integrations/Get-all-companies-throws-random-HTTP-500-errors/m-p/251587). Is this still happening for you now?

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [February 11, 2019, 1:33pm UTC](https://community.hubspot.com/t/looping-through-companies-api-i-randomly-get-an-error-part-way-through/12883/3 "2019-02-11T13:33:17Z")

</div>

Thanks for jumping in, [@hot\_z](https://community.hubspot.com/t5/user/viewprofilepage/user-id/84980).

@steveka, the issue you’re describing is almost certainly related to that issue, which should now be resolved.

Please let me know if you’re still encountering the behavior.

---

<div class="post-metadata">

**Author:** ![steveka](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/steveka/32/63860_2.png) [@steveka](https://community.hubspot.com/u/steveka)\
**Post date:** [February 11, 2019, 4:21pm UTC](https://community.hubspot.com/t/looping-through-companies-api-i-randomly-get-an-error-part-way-through/12883/4 "2019-02-11T16:21:15Z")

</div>

Thanks hot\_z,

Looks like it was a temporary condition, took a look at the hubspot status page when it was happening and didn’t see anything about api problems.
