APIs & Integrations

Not applicable

Get all forms from a portal doesn't return offset parameter

Hello,

We are trying to get all our forms in batches but when we are using the limit parameter
there isn’t an option to page through the results.
Offset parameter isn’t returned in the first request to get the next set of results as mentioned in:

Get all forms from a portal | Forms API

GET /forms/v2/forms - For a given portal, return all forms that have been created in the portal. Forms are standard website forms that can be used to generate website leads. For any form, there may be a set of fields associated with that form in...

This is the api call https://api.hubapi.com/forms/v2/forms?hapikey={hapikey}&limit=1
(we have more than 1 form)

We tried also with Hubspot demo account and got the same problem https://api.hubapi.com/forms/v2/forms?hapikey=demo&limit=1.

0 Upvotes
2 Replies 2
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Get all forms from a portal doesn't return offset parameter

Hi @Ofir,

After touching base with the team, it actually sounds like the language in the doc was incorrect. There isn't an offset parameter included in any response; rather, the offset value corresponds to which form you're looking to pull. The example I shared with you before is the correct way to page through the forms.

To reiterate; if you're requesting a single form, first you'd make this request:

https://api.hubapi.com/forms/v2/forms?hapikey={hapikey}&limit=1

Then, to get the next form, you'd make the following request to get the second form:

https://api.hubapi.com/forms/v2/forms?hapikey={hapikey}&limit=1&offset=1

And then the following request to get the third, and so on and so forth:

https://api.hubapi.com/forms/v2/forms?hapikey={hapikey}&limit=1&offset=2

The same process can be extended no matter how many forms you're requesting in a single batch. For example; to pull all your forms in batches of 10, you'd first make an initial request:

https://api.hubapi.com/forms/v2/forms?hapikey={hapikey}&limit=10

and then the following request to pull the next 10:

https://api.hubapi.com/forms/v2/forms?hapikey={hapikey}&limit=10&offset=10

Let me know if you have any questions. I'll work on getting the documentation updated asap.

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Get all forms from a portal doesn't return offset parameter

Hi @Ofir,

I can reproduce this issue on my end as well. I'll take this to the product team and see what might be going on. I'll update this thread when I have more information.

edit:
It appears that including the offset parameter will still allow you to page through the results. For example, if you make a request to https://api.hubapi.com/forms/v2/forms?hapikey={hapikey}&limit=1 you'll get the first form, and if you make a request to https://api.hubapi.com/forms/v2/forms?hapikey={hapikey}&limit=1&offset=1 you'll get the next form, and so on.

Since it appears you're requesting one form at a time, you can likely work around the issue for now by just incrementing offset by one with each request.