Retrieve object directly after creation not working

I integrated HubSpot into our application via the nodejs library. In order to test the integration, i had the following simple setup:

1. Create a new object

const { id } = await hubspotClient.crm.objects.basicApi.create(objectTypeId, {

properties: {

name,

customid,

}});

2. Retrieve object

const subscriptions = await hubspotClient.crm.objects.searchApi.doSearch(objectTypeId, {

filterGroups: [{

filters: [{

propertyName: ‘customid’,

operator: ‘EQ’,

value: customid,

}],

}],

limit: 1,

after: 0,

sorts: [],

properties: [‘name’, ‘customid’],

});

But the resulting page is empty. Only if I run add a 3sec delay on the second request I get a result.

Is this a generall limitation of the API or could this be related to our instance still being in trial? Or is there some other fix for this?

A documented limitation of the CRM Search APIs is that “It may take a few moments for newly created or updated CRM objects to appear in search results.” (doc). Your initial request should return an HubSpot object ID, however, which you should then be able to use to directly fetch the object by ID (“basicApi” rather than “searchApi” in the second request).