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.

Vote:
 

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?"

#322076
May 15, 2024 9:52
Vote:
 

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;

#322084
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.
Vote:
 

For now, we are calling the friendly URL to ensure that the not-found handler properly handles the request, as shown below.

When I use the following API endpoint, https://localhost:8080/api/episerver/v3.0/content?ContentUrl={ContentUrl}, it returns an empty array instead of a 404 response

#323368
Jun 10, 2024 9:55
* 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.