1

When I test my Lambda through AWS Gateway, I can see this lines being logged:

Wed Jul 19 20:06:11 UTC 2017 : Method response body after transformations: {"errorCode":0,"headers":{},"statusCode":567,"base64Encoded":false}

As you can see I'm returning 567 as status Code. But I always see 200:

enter image description here

Then, this is my configuration in Integration Response:

enter image description here

I'm using as reg exp .*"statusCode":567.*, but it is not matching with {"errorCode":0,"headers":{},"statusCode":567,"base64Encoded":false}.

These are my http status codes in Method Responses section:

enter image description here

I can not make return other than 200. I tried changing the default to be 567 instead of 200. That way it returns 567. So looks like my setting makes my API to return always the default response.

Does anybody have a clue of what I'm doing wrong?

Perimosh
  • 2,304
  • 3
  • 20
  • 38

2 Answers2

2

Try using lambda-proxy instead of lambda-integration.

This way, you construct your response in your lambda function and not in the API Gateway templates.

In my opinion, it's easier to manipulate the response in code rather than using API Gateway templates.

Noel Llevares
  • 15,018
  • 3
  • 57
  • 81
1

In this case, I think it is your regex that is at fault: .*"statusCode":567.*

It's matching on the internal JSON message, so it would need changed to .*\"statusCode\":567.* to match - this worked in my case anyway

I used this answer for mine, slightly simpler that what you are looking for.

matrim_c
  • 81
  • 1
  • 4
  • Thanks. Actually this was a long time ago, I'm not even using Lambda anymore for this. – Perimosh Oct 01 '18 at 20:22
  • I was working on this issue earlier and came across your question after I had finished - thought it might be useful for those not wanting to switch. Or as my case without the option to modify existing code – matrim_c Oct 01 '18 at 23:11