Question

OData custom error message

Hello Community,

 

I'm wondering is there any possibility to return custom error code and message upon OData POST validation ?

When i'm using entity object events (**Inserting, **Validating) then message generated by

- throw new...

- Entity.ValidationMessages.Add(...)

didn't overriting standard error response.

 

{"error":{"code":"","message":"An error has occurred."}}

 

Best Regards,

Marcin Kott

Like 0

Like

5 comments
Best reply

Dear Marcin,

 

That is correct. Since the OData POST requests are inserted directly into the DataBase they bypass the duplication search.

In this case the best solution would be running the Deduplication search after the POST request.

 

You may read more on Deduplication here:

1. https://academy.creatio.com/docs/user/on_site_deployment/containerized_…

2. https://academy.creatio.com/docs/user/platform_basics/business_data/dup…

 

Hope this clarifies!

 

Thank you!

 

Regards,

 

Danyil

 

 

I think the best way would be to create a Log -object/lookup which can hold all the error-messages.

Save the error-details in your new Log-object and view it to debug and such

Hello Julius,

 

This is not exactly my case. I would like to return error in a response body of the post method if inserted record didn't pass validation.

Dear Marcin,

 

Thank you for your question!

 

We can confirm that there is no solution on how to change the error code as of now as the error messages are not Creatio`s but OData`s alerts.



The reason you are receiving this error could mean that you have created several new sections and then tried to do a POST request to that section.

 

In order to fix this issue with the {"error":{"code":"","message":"An error has occurred."}} we recommend Updating the Database, Generating the Source Code and Recompiling the system.

 

UPD: The error with POST requests returning *An error has occurred* for custom sections has been fixed in Creatio versions starting from 7.18.3

 

Hope this clarifies!

 

Thank you!

 

Danyil

Hi Danyil,

 

Thank You for clarification. So it seems that there is no option to include deduplication detection when record is inserted via Odata Post ? I mean to return message to third party system that eg. Contact with such email already exists.

 

Regards,

Marcin

Dear Marcin,

 

That is correct. Since the OData POST requests are inserted directly into the DataBase they bypass the duplication search.

In this case the best solution would be running the Deduplication search after the POST request.

 

You may read more on Deduplication here:

1. https://academy.creatio.com/docs/user/on_site_deployment/containerized_…

2. https://academy.creatio.com/docs/user/platform_basics/business_data/dup…

 

Hope this clarifies!

 

Thank you!

 

Regards,

 

Danyil

 

 

Show all comments