Do I need to setup the Integration Response and Method Response for each 400 error

0

When working with API Gateway Integration Response and Method Response. We have multiple 400 errors, they all return the same formated object but the status numer changes.

I think I am not understanding this correctly. Do I need to setup the Integration Response and Method Response for each 400 error. It is a lot of duplication, in the integration response I am only returning $input.path('$.errorMessage'); in the Mapping templates.

Is the Method response status code what is passed as the response code? Is there a way to create one 400 Integration Response and Method Response and dynamically change the status code that gets passed as the response?

List of 400 errors 401 Access denied 402 Account inactive 404 Not found 406 Not acceptable 408 Request timeout 422 Request not processed 429 Too many requests

Sample of lambda error response { status: 422, statusText: "Unknown Error", message: "Unable to process.":, errors: [error01,error02], }

Thank You

1개 답변
0

One approach could be is to use a more generic 400 error code for client-side errors and include the specific error detail within the response body. This way, we can define a single Method Response and Integration Response for the 400 status code, and use the response body to convey the specific error (401, 402, 404, etc.).

profile pictureAWS
전문가
답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠