Comments for Test the APIs


Good afternoon… Today November 19, here in Costa Rica it’s 13:15… in this moment the command works fine again… I don’t understand why the command not works in the morning but It works in the afternoon…

I didn’t anything… the command that I executed in the morning is the same now:

e:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-client>npx aws-api-gateway-cli-test --username --password Passw0rd! --user-pool-id us-east-2_xGNazPJrI --app-client-id 1uiieiq7un5ahf2lbpdlbg7c5m --cognito-region us-east-2 --identity-pool-id us-east-2:5fa10a30-1bf7-448e-a8e7-3ebd26984511 --invoke-url --api-gateway-region us-east-2 --path-template /notes --method POST --body "{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}"
npx: installed 105 in 17.948s
Authenticating with User Pool
Getting temporary credentials
Making API request
{ status: 200,
  statusText: 'OK',
   { userid: 'us-east-2:1069b87e-7ef7-4ec3-a9d9-ddb143e73927',
     noteid: '67cb87d0-ec2f-11e8-ba45-bd4947f4c7ca',
     content: 'hello world',
     attachment: 'hello.jpg',
     createdAt: 1542654898381 } }


I’m not sure if you are using a different machine but sometimes the time related issues are because they use the local time to verify the generated signatures. Just make sure your system clock is okay.

Authenticating with User Pool

Getting temporary credentials

Making API request

Invalid character in header content ["Authorization"]

This is what I am currently stuck at. Is this saying there a typo somewhere…?? Please help. Thanks


Helo @jayair, thank you for your answer. I am using the same machine. I have Windows 10 64 bits.


In this morning I have the same problem again. Here in Costa Rica is November 26 09:47


I resolved my issue… just copy and pasted the text once more for the npx aws-api-gateway-cli-test command and re-entered in all of my details.

I suppose I had a typo in there somewhere…


Hello community, when using the aws-api-gateway-cli-test with npx has anyone come across this particular issue:

npx: installed 105 in 5.701s
Both UserPoolId and ClientId are required.

It’s strange, as far as I know I’m plugging in the correct credentials, I’ve even compared them to other examples I came across online, but this issue makes it seem as if I missed them, idk what’s the deal here but I also attempted to use “” instead of single quotes since I’m on a windows machine.

Any guidance, tip would be very much appreciated


Ok guys I figured it out, for anybody coming across the same issue run it without backslashes, equals or quotes

npx aws-api-gateway-cli-test --username --password Passw0rd! --user-pool-id us-east-2_TWW6wTMHO --app-client-id 59hps43j2vqc702ka502b3lq8k --cognito-region us-east-2 --identity-pool-id us-east-2:6ade526b-0056-4795-9b52-acae2ab53655 --invoke-url --api-gateway-region us-east-2 --path-template /notes --method POST --body "{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}"


I believe I know what is causing a good number of the issues mentioned in this thread. In many cases (and in mine) it had to do with the format of the quotes. If you are using a text editor such as notepad, word etc to formulate your command before pasting it into the terminal when you use the quote character it will encode it as a “curly-quote” i.e. ‘ Us-east-1 ’. If you have rich text turned off or are using an IDE you get the flat quotes i.e. ’ Us-east-1 ‘. The curly quotes will cause an issue. Its very hard to see the difference especially if your text is small but it’s there.

Instead of using npx I downloaded and installed the npm package globally. I ran the command described int he tutorial without npx and and added some console logs into the code to try and find the error.

It was passing the login argument to the aws-cognito SDK like so:
‘cognito-idp.‘us-east-1’’: eyJraWQiOiJ1U0pTblZIQVRub3…… rest of JWT….
Notice the extra quotes sandwiched within the string

My advice:

Use an IDE, plain text editor, or type directly into terminal to create your request

Don’t use quotes at all (expect for the —body argument, you need it there)

If you’re still having issues download the was-api-gateway-cli-test module (from GitHub or npm) and use whatever debugging tools your like to examine each step or customize the script to suit your needs. The serverless stack walkthrough has an extra credit chapter where they go into further detail about exactly what’s goin on here.

Hint: if installed globally the execute command is not aws-api-gateway-cli-test but apig-test


Glad you figured it out.


Thanks for sharing! Appreciate it.


Glad you figure it out!


This error is saying that the SSL Certificate that AWS is using is invalid. That really doesn’t make sense. Are you using some sort of a proxy?


I tried all of the suggestion, but still getting the following error. I’m using cmd on Windows.

Authenticating with User Pool
Getting temporary credentials
Making API request
            throw err;
SyntaxError: Unexpected token h in JSON at position 11
    at JSON.parse (<anonymous>)
    at makeRequest (C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\index.js:168:19)
    at C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\index.js:150:5
    at C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\credentials.js:123:23
    at Response.<anonymous> (C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\credentials\cognito_identity_credentials.js:258:7)
    at Request.<anonymous> (C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\request.js:364:18)
    at Request.callListeners (C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\request.js:683:14)
    at Request.transition (C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\request.js:22:10)

Cloudwatch log shows the following:

2018-12-07T07:18:12.490Z	4135015c-f9f0-11e8-81b0-a71705cba49f
    "errorMessage": "Cannot read property 'content' of null",
    "errorType": "TypeError",
    "stackTrace": [
        "_callee$ (/var/task/webpack:/create.js:12:21)",
        "tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:62:40)",
        "Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:296:22)",
        "Generator.prototype.(anonymous function) [as next] (/var/task/node_modules/regenerator-runtime/runtime.js:114:21)",
        "step (/var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)",
        "new Promise (<anonymous>)",
        "new F (/var/task/node_modules/core-js/library/modules/_export.js:35:28)",
        "main (/var/task/create.js:245:17)"


The CloudWatch log is saying that there some issue in the code? What does your create.js look like?


Hi all,

I followed the tutorial and made it pass the mock events but am now stuck at the API test. This is the command I am running and the error message that I get:

–body=’{“content”:“hello world”,“attachment”:“hello.jpg”}’

Authenticating with User Pool
Getting temporary credentials
Making API request
            throw err;

TypeError: Cannot read property ‘1’ of null
at Object.apigClientFactory.newClient (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-api-gateway-client/dist/apigClient.js:63:57)
at makeRequest (/usr/local/lib/node_modules/aws-api-gateway-cli-test/index.js:157:38)
at /usr/local/lib/node_modules/aws-api-gateway-cli-test/index.js:150:5
at /usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/credentials.js:123:23
at Response. (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/credentials/cognito_identity_credentials.js:258:7)
at Request. (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/request.js:364:18)
at Request.callListeners (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/request.js:22:10)

Appreciate any help I can get on this issue. Thanks!


Figured it out. I got the invoke-url and api-gateway-regions switched…


I keep getting this error, and I am totally stumped. Can anyone help? Thanks


spent ages looking into this and this fixed it. :slight_smile: thanks


@frandim Can you post the full command?