REST API: POST = Success then GET = Failure for same entity

I have been working with the Freshdesk REST API for the past few months now and have been experiencing a frustrating issue. When I create an entity (either a company or a contact) via a POST request, I get a return code of 200 indicating the entity has been successfully created, however, if I immediately try to retrieve that entity via the unique identifier I’m storing in a custom field (using the Filter Contact/Company functionality, which is still in beta) it will tell me no results are returned. I have to continually retry and eventually it will fetch the newly created entity but this delay can be anywhere from 5-60 seconds. Has anyone else experienced this?

What I’ve done as a workaround for the time being is created a for loop that continues to retry fetching the newly created entity every 15 seconds after it has been created and doesn’t break that loop until it is successfully fetched and then moves onto the next steps of my processing. This is, however, an inefficient way to operate and an excessive use of GET calls. Ideally when the POST endpoint returns a success code I should be able to immediately use a GET call to retrieve that record and have it be returned, but that’s not currently the case. If anyone from Freshdesk is looking at this, is this a known issue that’s being worked on? Other members of the community do you have any better suggestions for dealing with this?

In general indexing for search/filter, does involve a few seconds.

Instead of using the Filter APIs, please try the View a Contact API.
The response body of a successful POST request will have the Contact’s ID. You can use that to fetch the full contact object, instead of relying on the Filter API.
This would be a simple change, if you are hitting the API in the same thread. I am not sure if that’s the scenario in your case.

2 Likes

Thanks for that reply. I actually have two different functional pathways here, one is a place where I can (and have) leveraged the approach you’re talking about. I call the create company endpoint, store the Freshdesk ID that is returned, and then make a contact tied to that contact all within the same thread without any issues. However, there is a separate functional workflow where those actions don’t happen in the same thread and that’s where I’ve implemented the additional calls to confirm the newly created company is retrievable before creating the contact tied to the company. It sounds like this is just the way it’s currently functioning. Perhaps Freshdesk will resolve this in the future, or at least make the general indexing more performant (the wait time is fairly erratic currently as far as I can tell).