1

I've created a web site that when a button is clicked it accesses my AWS API Gateway endpoint which is set as a trigger for my AWS Lambda function. My Lambda function then runs a zip file of my java project.

Nothing is broken and all of this is working as I hoped except for one part: Because there are no HTTP Status responses in the project, the API Gateway just returns "null" when the Lambda function is finished. I can't seem to find a simply way of handling a "null" response to the user. I'd simply like to change it to display some sort of "Success" message.

So my question is, how can I handle a null response from my API Gateway without adding any code to my project?

3
  • I’d suggest you return the response headers from Lambda which is supposed to be the proxy integration of your API method. So that client would know whether the request was successful or not. Commented Jan 8, 2019 at 17:31
  • @AtharKhan Well, that's kind of the issue I'm trying to handle. There are no HTTP header responses from my Lambda function. So inside the "Integration Response" section of API Gateway there is no place for me to add a new response type of "null" and map that with a Response Model to display "success". Commented Jan 8, 2019 at 17:45
  • I'd keep it simple. Add your lambda as proxy integration in API gateway method and return following: { statusCode: 200, headers: { 'Access-Control-Allow-Origin': '*' }, body: 'Success' }; } Commented Jan 8, 2019 at 18:58

1 Answer 1

1

Fixed. Under the API Integration Response, Mapping Template, I generated an empty template:

#set($inputRoot = $input.path('$'))
{
     "message": "Test complete."
}

Then redeployed the API.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.