Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: V2 query parameters need to be exploded #38

Merged
merged 1 commit into from
Sep 4, 2024
Merged

Conversation

joscha
Copy link
Member

@joscha joscha commented Sep 4, 2024

Fixes an error that reads:

[...,last-event,next-event] are not valid Field IDs for this endpoint. Make sure that they all refer to non-list-specific company fields.","param":"fieldIds"}]}

when trying to access the /v2/companies endpoint with a set of fieldIds.

Happens when trying to load companies from the /v2/companies endpoint with all available fields. For this, I am using the V2 API roughly as follows:

// get 100 company fields
const fields = (await companiesApi.getV2CompaniesFields({ limit: 100 })).data;
// get the IDs for all these fields
const fieldIds = fields.map(({id}) => id);
// get 100 companies with these fields
const companies = await companiesApi.getV2Companies({ limit: 100, fieldIds });

It generates a URL that roughly looks like:

https://api.affinity.co/v2/companies?limit=100&fieldIds=field-1142774%2Cfield-1142835%2Cfield-2122251%2Cfield-2123931%2Cfield-2130433%2Cfield-2148488%2Cfield-2287286

(comma-separated), but the API definition is

"explode": true,

which means it should generate as &fieldIds=fieldName1&fieldIds=fieldName2, etc.

Fix based on OpenAPITools/openapi-generator#19519

@joscha joscha merged commit 47550cf into main Sep 4, 2024
8 checks passed
@joscha joscha deleted the joscha/v2-query-fix branch September 4, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant