APIs & Integrations

Not applicable

I am getting this error if i specify limit=300 "The remote server returned an error: (400) Bad Request."

SOLVE

I have the following api call to get all the companies details, where currently we have 8700++ companies created inside HubSpo :-

https://api.hubapi.com/companies/v2/companies/paged?hapikey=***************&properties=website&prope...

now i wanted to get all the companies we have, but the above API will return 100 records only. so i try to define a limit of 300 (just for testing) as follow:-

https://api.hubapi.com/companies/v2/companies/paged?hapikey=***************&properties=website&prope...

but i got this error:-

Message = "The remote server returned an error: (400) Bad Request."

so can i know how we can get all the companies records we have (the 8700++ companies)? and can this be done using one API call ?

0 Upvotes
1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

I am getting this error if i specify limit=300 "The remote server returned an error: (400) Bad Request."

SOLVE

Hey, @johnjohn123.

Again, the documentation states:

In addition to the list of companies, each request will also return two values, offset and has-more . If has-more is true, you'll need to make another request, using the offset to get the next page of company records.

So, your first request will return up to 250 company records and:

"has-more": true,
"offset": some_value

Your next request will include offset=some_value and so forth.

Isaac Takushi

Associate Certification Manager

View solution in original post

0 Upvotes
3 Replies 3
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

I am getting this error if i specify limit=300 "The remote server returned an error: (400) Bad Request."

SOLVE

Hey, @johnjohn123.

Again, the documentation states:

In addition to the list of companies, each request will also return two values, offset and has-more . If has-more is true, you'll need to make another request, using the offset to get the next page of company records.

So, your first request will return up to 250 company records and:

"has-more": true,
"offset": some_value

Your next request will include offset=some_value and so forth.

Isaac Takushi

Associate Certification Manager
0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

I am getting this error if i specify limit=300 "The remote server returned an error: (400) Bad Request."

SOLVE

Hey, @johnjohn123.

Per the endpoint documentation, the maximum value of the limit property is 250.

It's not possible to retrieve all 8,700+ company records in one API call. As the documentation notes, you'll have to make multiple requests and page through the results. If you use limit=250, this will take at least 35 calls.

Isaac Takushi

Associate Certification Manager
0 Upvotes
Not applicable

I am getting this error if i specify limit=300 "The remote server returned an error: (400) Bad Request."

SOLVE

ok fine. but in my case how i can modify the url for the API calls to be able to retrieve all the 8700++ records by getting 250 on each request ? can i define a "skip" & "take" parameters inside the api url ?

0 Upvotes