The loadAttachmentUrl operation returns a 200 OK response code and an error response body

Hi all.

I encountered a scenario where downloading an attachment in a form failed but the UI did not react or display any indication of the failure. I noticed that although the request to load the attachment URL returned a 200 OK response code, the response body appeared like this:

I think this issue is most likely related to the loadAttachmentUrl operation of the Dataservice or it’s possible that the attachment handler’s error handling does not cover this specific scenario.
Should this scenario be handled?

Hello,

that’s JSON-RPC 2.0 specification. If there is an application error, it’s presented on the JSON-RPC level, not on the HTTP one. So the 200 OK is correct even if there was an error processing the single operation. See the typescript - JSON-RPC v2 API. HTTP Layer. What are the appropriate HTTP Layer status codes for API responses? - Stack Overflow. There are additional links in this post leading to the specs.

If you wish to display the message to the user, you must parse the error messages in UI and display it to the user. You can either rely on the error code, or you can use the message provided.

Thanks for the explanation, @petr-high-peak