Skip to content

Error while calling basicApi.getById only with propertiesWithHistory #674

@hunorszondi

Description

@hunorszondi

Hello!

The problem

While calling the basicApi.getById method on the deal object to get ONLY the historical info about the a property, for instance dealstage, like:

  • hubspotClient.crm.objects.basicApi.getById('deal', hubspotRecordId, null, ['dealstage'])
    or
  • hubspotClient.crm.deals.basicApi.getById(hubspotRecordId, null, ['dealstage'])

I got the following error trace:

TypeError: serializedParams is not iterable at BasicApiRequestFactory.<anonymous> (app/node_modules/@hubspot/api-client/lib/codegen/crm/objects/apis/BasicApi.js:95:47) at Generator.next (<anonymous>) at app/node_modules/@hubspot/api-client/lib/codegen/crm/objects/apis/BasicApi.js:8:71 at new Promise (<anonymous>) at __awaiter (app/node_modules/@hubspot/api-client/lib/codegen/crm/objects/apis/BasicApi.js:4:12) at BasicApiRequestFactory.getById (app/node_modules/@hubspot/api-client/lib/codegen/crm/objects/apis/BasicApi.js:80:16) at ObservableBasicApi.getByIdWithHttpInfo (app/node_modules/@hubspot/api-client/lib/codegen/crm/objects/types/ObservableAPI.js:131:59) at ObservableBasicApi.getById (app/node_modules/@hubspot/api-client/lib/codegen/crm/objects/types/ObservableAPI.js:146:21) at PromiseBasicApi.getById (app/node_modules/@hubspot/api-client/lib/codegen/crm/objects/types/PromiseAPI.js:97:33) at RetryDecorator.<anonymous> (app/node_modules/@hubspot/api-client/lib/src/services/decorators/RetryDecorator.js:32:43)

This happens because serializedParams is checked to see if it's not undefined. However, in my case it is null, so the code tries to iterate over the null value, hence the error.

I updated the @hubspot/api-client from v12.0.1 to v13.40.0 when the issue appeared.

Quick fix for the ones facing this issue until it's solved

Method 1: Use undefined instead of null for the properties parameter.

Method 2: Use the propertiesWithHistory parameter as the properties, like

const properties = ['dealstage']; 
hubspotClient.crm.objects.basicApi.getById('deal', hubspotRecordId, properties, properties)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions