-1

When trying to test my AWS REST API POST method that's connected to my Java Lambda function, I get an error {"message": "Internal server error"} when I pass in: userID=5&name=test as a query string like so: enter image description here

I want to do the same as thing as going into Lambda Test console and typing in:

{ "userID": 5 "name": "test" } 

in the "Event JSON" part (which works fine in Lambda), but when I try to replicate it through the API, it doesn't work.

This is my Java code:

import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.LambdaLogger; import com.amazonaws.services.lambda.runtime.RequestHandler; public class Launcher implements RequestHandler<Launcher.CompanyRecord, String>{ public String handleRequest(CompanyRecord event, Context context) { return String.valueOf(event.userID) + event.name; } record CompanyRecord(int userID, String name) { } } 

I've also tried passing in

{ "userID": 10, "name": "test" } 

in the Headers and Request Body (independently), but I still get the same {"message": "Internal server error"}

4
  • More info about your request would be helpful. You say you 'pass in a query string'. Is that as part of the URL? A message body? What mime-type are you sending? What client are you using to send the request? Similar questions may help clarify: stackoverflow.com/questions/32057053/… Commented Aug 8, 2023 at 18:29
  • Have you checked the logs? It should show the stacktrace. Commented Aug 8, 2023 at 18:47
  • @cmonkey - I edited the post to add a picture to detail exactly what I did. I hope that clarifies what I did Commented Aug 8, 2023 at 18:51
  • @AbhijitSarkar Yes, I'm getting an error: "Execution failed due to configuration error: Malformed Lambda proxy response" Commented Aug 8, 2023 at 18:53

1 Answer 1

0

I found the mistake. I had "Use Lambda Proxy integration" on when creating the method. After turning it off, it worked when I put the JSON in the request body of the POST request like so: enter image description here

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.