The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

529583 (3) [Avatar] Offline
#1
I have a problem with the exercise at the end of Chapter 3. Using the solution code in the book, the following cases work: passing in both a greeting and username, passing in a greeting but no username, and passing in no greeting and no username.

However, if you try to pass in a username but no greeting, the request body mapping template spits out an empty json object to the lambda function, essentially just causing the username to disappear into thin air. This is quite bewildering as it's definitely going to the right route and lambda function, but for the case of a username but no greeting, it just throws out the username.

Anyone have any ideas?
adamba (6) [Avatar] Offline
#2
In the Integration Request, what is your Body Mapping Template for application/json?
150034 (6) [Avatar] Offline
#3
There doesn't appear to be an easy answer to this problem.

If you change the body mapping template for the integration request to generate a Method request passthrough and then run test events with a username but no greet, you'll see that the path object is empty in the endpoint request body. On the other hand, the object is not empty if only a greet is set but no username.

In other words, the body mapping template can't work, because API Gateway is not passing the username parameter when the greet parameter is missing.