Try ERPNext Buy Support Partners Foundation

How to get JSON error response from ErpNext API?

Is there a way to tell the ErpNext REST API to return a JSON response when an error occurs?

I’ve been scrolling back and forth through reams of HTML to find error messages and it just occurred to me – “This isn’t even remotely normal! Since when does a computer to computer interface return a computer to human response to report an error?”

1 Like

It’s an inconsistent design. That said, fixing it would require changing your app.py file or changing the way that errors are handled in the front end of frappe.

That flag is set to False and is not available outside that function. It’s set another half dozen times below there as well.

1 Like

So it’s a candidate for a feature request in GitHub?

1 Like

Yes, I would say so

Sorta what I thought, but …

… am I really the first to ask about this?

It’s quite an egregious breach of the REST “contract”, don’t you think?

nope: https://github.com/frappe/frappe/issues/6201

This is just a workaround, it doesn’t solve the issue. If the api consumer app can handle the response something like following can be done:

if EMPLOYEE_NOT_FOUND_ERROR_MESSAGE in error_str