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:
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 I have a rule There are also paths like Traffic in my So basically the And if somehow the API is located in the same way as the path of this domain: This can be something like this: normal Target any .htaccess file on it on your server or open the web application.
http://api.mygreatserver.net/error/422
.htaccess :
RewriteRule ^ ([az _-] +) / ([0- 9] +) /? $ Index.php? Controller = $ 1 & amp; ID = $ 2 [QSA]
/ 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!
http://www.mygreatserver.net/api/error/422
error document 422 / API / error / 422
422 for a predetermined path in your control and then within that controller, send the custom content you want.
Comments
Post a Comment