Try our conversational search powered by Generative AI!

changing the behavior of the content delivery API so that it returns a 404 error instead of an empty array when content is not found.


I'm working on a project using Optimizely CMS and commerce. We're doing A/B Testing and using a not-found handler from Geta. The issue is, we call the content delivery API twice for each page load, causing double views. I tried creating a custom provider to handle not-found content, but it returns an empty array instead of a 404 error. Can we change it to return a 404 error instead?"

May 15, 2024 9:52

Are you saying that the response returned from ContentDelieveryApi is not 404 for empty response? If so, then can you tell what specific api you are triggering?

And, if you are facing issue in returning 404 response for customApi contoller, then, you probably will need to change the response code manually like.

Response.StatusCode = 404;

May 15, 2024 16:15
Praful Jangid - May 15, 2024 16:16
If possible Momen, can you share the code example to get more context about.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.