APIs & Integrations

bubbly1
Member

"Get all companies" API: only the first query string parameter is seen

SOLVE

Hi. I'm using the /companies/v2/companies/paged API, and including multiple "properties=" parameters, e.g.:

https://api.hubapi.com/companies/v2/companies/paged?properties=name&properties=districtcode&properti...

("districtcode" and "buildingcode" are properties I created)

but the API seems to only ever return the property associated with the first "properties=" specification.

Am I specifying the parameters incorrectly? Or....?

(I verified I can obtain all those properties individually when spelled as in the multiple parameters case.)

0 Upvotes
1 Accepted solution
bubbly1
Solution
Member

"Get all companies" API: only the first query string parameter is seen

SOLVE

Thanks @Derek_Gervais,

Your reply had me taking a deeper look at what I was doing. While I was formatting the URLs correctly, I was passing the string to popen(), which of course was leading to the unquoted '&' characters being taken to mean "run in the background"! :slight_smile:

Regards,
Steve

View solution in original post

0 Upvotes
4 Replies 4
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

"Get all companies" API: only the first query string parameter is seen

SOLVE

Hi @bubbly,

I see! That's pretty sneaky; nice catch, and thanks for posting your solution here on the topic! I'll mark this as solved so that others with similar issues can benefit.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

"Get all companies" API: only the first query string parameter is seen

SOLVE

Hi @bubbly,

I'm not able to reproduce this issue on my end; all query parameters are process properly when I make requests (regardless of order). Is it possible that there some encoding/processing/templating error that's occurring when the values are being inserted into the URL? For example, if I'm dynamically appending query parameters, the first ? might be hard coded, so the first parameter works fine. But if the code that's appending subsequent parameters is omitting the & or using a ? or the parameters are otherwise malformed (for a few examples) then all but the first query parameter would likely be ignored.

0 Upvotes
bubbly1
Solution
Member

"Get all companies" API: only the first query string parameter is seen

SOLVE

Thanks @Derek_Gervais,

Your reply had me taking a deeper look at what I was doing. While I was formatting the URLs correctly, I was passing the string to popen(), which of course was leading to the unquoted '&' characters being taken to mean "run in the background"! :slight_smile:

Regards,
Steve

0 Upvotes
bubbly1
Member

"Get all companies" API: only the first query string parameter is seen

SOLVE

The original title of this post was ""Get all companies" API returns only the first "properties=" parameter specified".

Since noting a property value was being returned for only the first "properties" parameter specified, I went on to attempt using "limit=" and "offset=" to obtain all my company records.

In my first attempt, subsequent requests kept returning the same JSON data, including offset value, which mean the "paginating" wasn't making any progress.

Remembering how this same API would never return data for a "properties=" beyond the first, I decided to reorder parameters on my subsequent GET calls.

Lo and behold, putting offset= first led to the offset value changing from call to call, but then the "properties=" parameter was being ignored.

So there's something not quite right about /companies/v2/companies/paged's handling of parameters in the query string. Seems like the API is only ever seeing the very first parameter in the query string.

0 Upvotes