Comments for Test the APIs

npx aws-api-gateway-cli-test --username='**********' --password='Passw0rd!' --user-pool-id='us-east-1_**********' --app-client-id='*********' --cognito-region='us-east-1' --identity-pool-id='us-east-1:****************' --invoke-url='' --api-gateway-region='us-east-1' --path-template='/notes' --method='POST' --body='{"content":"hello world","attachment":"hello.jpg"}'


Because I’m new to this … I’m not sure how much information I should share. I’m happy to share a lot more with you over email.


So from the looks of it is not accessible. Either there is a typo there or it has not been deployed. Can you double check how you got that URL?



I pulled the URL from the following tutorial … Should it be something different?


I resolved the issue the URL was the wrong URL. I found the correct URL through searching on the AWS console for API Gateway. In the API Gateway if you go to stages on the left hand side and click on it the URL will be at the top. Also, I SPENT FOREVER WONDERING WHY THE COMMAND WAS WRONG!!! If you are a mac user ad you are getting the following error when you copy the command over

Missing required arguments: password, user-pool-id, app-client-id, identity-pool-id, invoke-url, path-template

it is because the terminal text has a different ASCII representation for the - character than what is represented in the latest version of chrome (Sep. 2018). You just have to type the entire command yourself.


Alright. I looked around my logs a bit more and saw something that might be helpful. Thanks so much for your help!

(33c0be38-a3f3-11e8-86d4-377179dedb87) Sending request to

(33c0be38-a3f3-11e8-86d4-377179dedb87) Received response. Integration latency: 616 ms

(33c0be38-a3f3-11e8-86d4-377179dedb87) Endpoint response body before transformations:

{ "errorMessage": "callback called with Error argument, but there was a problem while retrieving one or more of its message, name, and stack" }

(33c0be38-a3f3-11e8-86d4-377179dedb87) Endpoint response headers: {X-Amz-Executed-Version=$LATEST, x-amzn-Remapped-Content-Length=0, Connection=keep-alive, x-amzn-RequestId=33c37d4b-a3f3-11e8-a8cc-3b71f0e28a0d, Content-Length=140, X-Amz-Function-Error=Unhandled, Date=Sun, 19 Aug 2018 21:02:38 GMT, X-Amzn-Trace-Id=root=1-5b79daed-afc7c097381c45a6c80df26c;sampled=0, Content-Type=application/json}

(33c0be38-a3f3-11e8-86d4-377179dedb87) Execution failed due to configuration error: Malformed Lambda proxy response

(33c0be38-a3f3-11e8-86d4-377179dedb87) Method completed with status: 502


I got it to work.

I think the error happened when I refactored my code for the create.js file.

I had left this part in my create.js file

AWS.config.update({ region: "us-east-1" });
const dynamoDb = new AWS.DynamoDB.DocumentClient();

while taking out the call to import AWS

import AWS from "aws-sdk";

That’s why Cloudwatch gave the reference error.

I went camping for 3 weeks otherwise I would’ve probably found it sooner.

Or maybe I found out the bug so easily because I left the tut for three weeks…

Either way
Thanks so much for your help!


OH yeah the URL is what we have in the tutorial. You need to replace it with yours.

Was the copy and Paste issue just on Chrome? That’s really strange.


Glad you figured it out! Thanks for reporting back.


NOTE, no question:

Hey Guys,
i was trying to use the apig-test command on Windows with the command for windows specified in the chapter.
the were errors coming up.

`Path must be a string. Received undefined`


`SyntaxError: Unexpected token \ in JSON at position 1.` 

The execution failed in the end and the API was not called.

Beware that this error occured with the Power Shell Terminal Application.

By running the code in the standard Command Prompt (cmd), the command worked perfectly fine (although the Path must be a string. Received undefined error still showed up) , the API request worked and a dynamoDB entry (according to the POST-function) was created.

Hope this helps someone

Have a great day



Thanks for posting about the issue. We haven’t offered a lot of support for Windows, so this should help.


When I hit this code below,

npx aws-api-gateway-cli-test \

I got only got this.

Authenticating with User Pool
Only custom auth (lambda driven) is enabled for this client.

Could you guys have any ideas to solve it???


This worked for me. Thanks.

I still dont know why because it worked once, then stopped.


  1. Go to Aws IAM console.
  2. Search roles for lambdaRole and click to open role.
  3. Click attach policies button and search for AdministratorAccess and attach it.
  4. Run same command that failed and it works. Didnt redeploy.


@jayair - Thanks for this wonderful tutorial, kudos!

I am getting the same cryptic 403 message that so many here have got. I went through the comments but wasn’t able to comprehend what’s going wrong.

Here is the request that I am making -
npx aws-api-gateway-cli-test --username --password Passw0rd! --user-pool-id us-west-2_kXXXeqxG --app-client-id QWmXXXv9m5p0u2ca0 --cognito-region us-west-2 --identity-pool-id us-west-2:1608cXXX420-9018-387bf6cb47c6 --invoke-url --api-gateway-region us-west-2 --path-template /notes --method POST --body "{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}"

Response -
npx: installed 1 in 3.943s Path must be a string. Received undefined npx: installed 105 in 13.956s C:\Users\XXX\AppData\Roaming\npm-cache\_npx\19376\node_modules\aws-api-gateway-cli-test\index.js Authenticating with User Pool Getting temporary credentials Making API request { status: 403, statusText: 'Forbidden', data: { message: 'Forbidden' } }

I am using bash on Windows, but I tried the same in cmd and PowerShell as well. Also, I tried using .../prod/ as the invoke-url parameter, and notes as the path-template parameter, to which I get a 500 Internal Server Error.

Correspondingly, I realized that the formatting in the .yml file was incorrect, in that iamRoleStatements was indented similarly to provider. I corrected that but to no avail.

Here is what the CloudWatch log says -
2018-10-13T10:44:58.117Z 062373-ced5-1x8-8406-273fca41c531 { AccessDeniedException: User: arn:aws:sts::318XX5417:assumed-role/notes-app-api-prod-us-west-2-lambdaRole/notes-app-api-prod-create is not authorized to perform: dynamodb:PutItem on resource: arn:aws:dynamodb:us-west-2:318XXX65411:table/notes at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:48:27) at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20) at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14) at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10) at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12) at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9) at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12) at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:115:18) message: 'User: arn:aws:sts::31765451845:assumed-role/notes-app-api-prod-us-west-2-lambdaRole/notes-app-api-prod-create is not authorized to perform: dynamodb:PutItem on resource: arn:aws:dynamodb:us-west-2:XXXXX4X:table/notes', code: 'AccessDeniedException', time: 2018-10-13T10:44:58.115Z, requestId: 'XXX', statusCode: 400, retryable: false, retryDelay: 13.389397756451215 }

My serverless.yml file is this -

And lastly, my package.json -
{ "name": "notes-app-api", "version": "1.1.0", "description": "A Node.js starter for the Serverless Framework with async/await and unit test support", "main": "handler.js", "scripts": { "test": "jest" }, "author": "", "license": "MIT", "repository": { "type": "git", "url": "" }, "devDependencies": { "aws-sdk": "^2.332.0", "babel-core": "^6.26.3", "babel-loader": "^7.1.4", "babel-plugin-source-map-support": "^1.0.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.7.0", "babel-preset-stage-3": "^6.24.1", "jest": "^21.2.1", "serverless-offline": "^3.25.6", "serverless-webpack": "^5.1.0", "webpack": "^4.16.2", "webpack-node-externals": "^1.6.0" }, "dependencies": { "babel-runtime": "^6.26.0", "source-map-support": "^0.4.18", "uuid": "^3.3.2" } }

Greatly appreciate the help :slight_smile:


@jayair - I feel stupid now. The same command worked in cmd for Windows, there was an issue with the terminal I was using.

Note: For Windows 10 users, prefer using the cmd prompt to execute these commands.


Glad you figured it out. Our Windows instructions aren’t great.


I can’t get past the ‘User does not exist.’ message. No idea what I’m doing wrong or missing, but I recreated my identity pool, still says that I don’t have any users in it, but my cognito pool has the user in it created from the instructions. Not sure what I’m missing. Any ideas?


When are you seeing this error message?


Just when testing the API now that it exists in AWS now. I’m guessing I have something wrong with the user setup but I haven’t found where yet. I see this error from the cli after I call the test method that is supposed to create a record on the server.