apache - Passing JSON error responses via HTTPD -


The team I work with is making an API interface for their application so that the data is exposed on that website Can be done, they are sending requests and responses in the JSON format but are currently binding on these issues.

They requested that the required data is missing with the 422 error code.

422 Unrecognized Unit (WebADV; RFC 4918) - The request was made well but due to semantic errors, the compliance could not be done.

The request is processed and the valid JSON response object is returned to the application server, but the HTTPD server is currently blocking the response and putting a generic error document for the 422 error Used to be.

To see if there is any way:

  • Disable error document interference and JSON response from application server transparently through Apache server Back
  • Use the error document handler, but inject the response body in the return message - that is,

    error document $ 422 $ {RESPONSE_BODY}

    Any other suggestions would be welcome. Our interim solution is to define the error code in return for only 200 responses and in response, but if possible it will use the HTTP error code.

    Without knowing the URL structure of my API, I give some suggestion that I am in the Jason API Which I've used, uses PHP for the framework. Place the .htaccess file on it on your server or open the web application. Error code URL sends in path. Assuming that your server setup is with you:

      http://api.mygreatserver.net/error/422   

    I have a rule There are also paths like Traffic in my .htaccess :

      RewriteRule ^ ([az _-] +) / ([0- 9] +) /? $ Index.php? Controller = $ 1 & amp; ID = $ 2 [QSA]   

    So basically the / error / 422 gets converted to index.php? Controllers = Error & amp; Id = 422 works on PHP script routes for error and then error on 422 ? At, voice!

    And if somehow the API is located in the same way as the path of this domain:

      http://www.mygreatserver.net/api/error/422   

    This can be something like this:

      error document 422 / API / error / 422   

    normal Target any 422 for a predetermined path in your control and then within that controller, send the custom content you want.

  • Comments

    Popular posts from this blog

    Java - Error: no suitable method found for add(int, java.lang.String) -

    java - JPA TypedQuery: Parameter value element did not match expected type -

    c++ - static template member variable has internal linkage but is not defined -