Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return nothing in AWS API Gateway?

Sorry for this dumb question, but I tried everything.

I have a AWS API Gateway from a Lambda function that I need to return only HTTP Code 200 with no body. If the lambda returns a empty string, the body shows "" (2 quotation marks). If the lambda returns null, the body shows the word null.

What is the catch? How to return a empty body?

For information, I am using a Slack dash command to call the API. So the call returns a HTTP 200 OK, and the result is sent by POST in a response url; so processing can be done after the HTTP result, in order to avoid timeout problems.

like image 349
TNT Avatar asked May 12 '17 13:05

TNT


1 Answers

If you are using the "lambda proxy integration" in the "integration request" section (see attached screenshot), you can simply return an empty string through the following structure.

enter image description here

module.exports.hello = (event, context, callback) => {
  const response = {
    statusCode: 200,
    body: ''
  };
  callback(null, response);
};
like image 110
jens walter Avatar answered Sep 25 '22 06:09

jens walter