2

I'm trying to locally test the AWS Gateway Api locally and have been following this site (among others). I've pulled down multiple example repo's and tried to get it working and have struck out so far. For reference the most recent repo I've tried to get working is here. After running sam local start-api in PowerShell I use Postman to call the endpoint and this is the error message that I see:

Invoking InventoryManagerDemo::InventoryManagerDemo.Lambdas.GetPalletFunction::GetPallet (dotnetcore2.1)
Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-dotnetcore2.1:rapid-1.7.0.

Mounting C:\SourceCode\Test\InventoryManagerAWS as /var/task:ro,delegated inside runtime container
Could not find the required 'InventoryManagerDemo.deps.json'.  This file should be present at the root of the deployment package.: LambdaException

START RequestId: bd07d65a-e632-1843-135b-7de4b1074c47 Version: $LATEST
END RequestId: bd07d65a-e632-1843-135b-7de4b1074c47
REPORT RequestId: bd07d65a-e632-1843-135b-7de4b1074c47     Init Duration: 125.55 ms        Duration: 1.86 ms       Billed Duration: 100 ms Memory Size: 256 MB     Max Memory Used: 37 MB
Lambda returned empty body!
Invalid lambda response received: Invalid API Gateway Response Keys: {'errorMessage'} in {'errorMessage': 'InvalidErrorShape'}
2020-10-30 16:18:53 127.0.0.1 - - [30/Oct/2020 16:18:53] "GET /GetPallet/1 HTTP/1.1" 502 -

I find the InventoryManagerDemo.deps.json at InventoryManagerAWS\InventoryManagerDemo\bin\Debug\netcoreapp2.1\. I've tried pulling that out and putting it at the root directory just to try something and that didn't work. Has anyone gotten this working? Any help would be much appreciated!

Mike R
  • 51
  • 5

1 Answers1

0

I was having this issue as well. In my case I found that it worked once I went into the .aws-sam\build directory and run sam local start-api from there.

More detail

So in the root of your project (where the csproj file is) run
sam build -t <templateName> e.g. sam build -t serverless.template

This will create a folder called .aws-sam in that same root folder. From the command line you can navigate into that folder and into the build subfolder. Note that if the build fails then the build folder will be empty. Inside the build folder you will see subfolders for each of your functions as well as a template.yaml file.

Inside the build folder (where the template.yaml file is located) is where you should run sam local start-api.

The folder where you should run the api command will look something like this:
C:\Users\username\source\repos\someapp\functionproj\.aws-sam\build

josephbales
  • 48
  • 1
  • 6