Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"message" : "Internal server error" issue with Lambda/API Gateway and iOS

I've set up a lambda function and created some GET and POST methods inside the API Gateway which seem to work fine when testing them inside the web application. I am then trying to call the functions inside an iOS application which is set up using the mobile hub. The functions also work inside the testing facility via the mobile hub perfectly fine, however when I actually test the functions inside the app I get:

"message" : "Internal server error"

I know the error is not much to work from, but I can't figure out a way to get a more detailed error description.

Any ideas?

like image 780
user3599895 Avatar asked Jul 15 '17 16:07

user3599895


People also ask

How do you handle Lambda errors in API gateway?

Make sure that you also set up the corresponding error code ( 400 ) on the method response. Otherwise, API Gateway throws an invalid configuration error response at runtime. At runtime, API Gateway matches the Lambda error's errorMessage against the pattern of the regular expression on the selectionPattern property.

How do I troubleshoot AWS Lambda?

To troubleshoot Lambda code errors You can use CloudWatch to view all logs generated by your function's code and identify potential issues. For more information, see Accessing Amazon CloudWatch Logs for AWS Lambda.

What is the difference between API gateway and Lambda?

AWS API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. Lambda is function as a service(FAAS) product of AWS. The combination of these two services is amazing and it is slowly replacing the traditional backend.


1 Answers

This may happen because your Lambda function is not set to return a HTTP status code.

Changing from

exports.handler = (event, context, callback) => {
    callback(null, 'Hello from Lambda');
};

to

exports.handler = (event, context, callback) => {
    callback(null, { statusCode: 200, body: 'Hello from Lambda' });
};

Should fix the issue.

like image 131
Ricardo Mayerhofer Avatar answered Nov 16 '22 02:11

Ricardo Mayerhofer