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 admin@example.com --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 https://qp6797jm09.execute-api.us-east-2.amazonaws.com/prod --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',
data:
{ 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.
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.
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’.amazonaws.com/us-east-1_m8tac7hqy’: 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
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
C:\Users\HP\AppData\Roaming\npm-cache\_npx\26548\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\request.js:31
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)
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:
Authenticating with User Pool
Getting temporary credentials
Making API request
/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/request.js:31
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!