Wow that’s really annoying. I think we are going to work on adding some tooling to fix these typo related issues.
Does the stack trace show you which line is causing it?
Hi Jay, sorry should’ve replied before, I think the error was that I had deleted that user lol, it’s working ok now. Thanks for the support!
Yeah, MS can drive you insane with this type of stuff sometimes! Thanks for the no-space tip - was pulling hair for over an hour
Also, need to add that -path-template parameter eliminates the ‘note’ at the end of the URI.
I’ve been getting an error,
since I’m new to this, I’m not too sure why it’s happening. I followed every step of the tutorial and even went throught the tutorial again. If i change the userpool to legacy, it will say “user does not exist” even though I have a cognito pool and one user on it. Can anyone help me out?
Can you give more info? Where in tutorial this happens? What are you doing to get this error?
so in the chapter for test the api,
after running
npx aws-api-gateway-cli-test
while getting authorized pool, it will print that error. Even tho i have an user created in the cognito pool, it will not work properly. Also, I tried changing the cognito pool to legacy instead of recommended one, it will return me “user does not exist” so I’m assuming that’s the reason I get that error message.
Oh that’s strange. Can I see the full command and the output? And the legacy option that you tried?
getting the error:
{
status: 403,
statusText: ‘Forbidden’,
data: { message: ‘User: arn:aws:sts::********4667:assumed-role/Cognito_notesidentitypoolAuth_Role/CognitoIdentityCredentials is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-east-1:********4667:lyu7es9gx1/prod/POST/notes’ }
}
and haven’t found a fix for it in this thread yet.
getting the error:
Authenticating with User Pool
Getting temporary credentials
Invalid login token. Couldn’t verify signed token.
seems like something simple but can’t figure it out
fixed this issue with aws configure
I got the 403 issue and fixed it by going to IAM and change the permissions to something like this:
arn:aws:execute-api:us-east-1:YOUR_ACCOUNT_ID:API_ID/prod/*/*
The tutorial was asking us to do this:
arn:aws:execute-api:YOUR_API_GATEWAY_REGION:*:YOUR_API_GATEWAY_ID/*/*/*
which should be updated
Ok I realized these two arns are actually pointing to the same thing.
My original problem that caused the 403 was when I was replacing YOUR_API_GATEWAY_REGION
, I also deleted the following :*
which represents any account id. That caused the arn to be invalid.
Thanks for following up with your solution. It just helped me fix a similar issue. Cheers!
Glad you figured it out!
Hi @jayair (and every one else), I’ve deployed serverless APIs accordingly to the chapters up to this point and met with the following errors when I’m issuing the command to test the APIs on Windows command line:
npx aws-api-gateway-cli-test --username admin@example.com --password Passw0rd!
--user-pool-id us-west-2_xxxxxxx --app-client-id xxxxxxxx --cognito-region us-west-2 --identity-pool-id us-west-2:xxxxx-xxxxx-xxxxxx
--invoke-url https:://j7l54gk0i9.execute-api.us-west-2.amazonaws.com/prod
--api-gateway-region us-west-2 --path-template /notes
--method POST --body "{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}"
npx: installed 110 in 8.321s
Authenticating with User Pool
Getting temporary credentials
Making API request
C:\Users\xyz\AppData\Roaming\npm-cache\_npx\45824\node_modules\aws-api-gateway-cli-test\node_modules\aws-api-gateway-client\dist\apigClient.js:64
var endpoint = /(^https?:\/\/[^\/]+)/g.exec(invokeUrl)[1];
^
TypeError: Cannot read property '1' of null
at Object.apigClientFactory.newClient (C:\Users\leete\AppData\Roaming\npm-cache\_npx\45824\node_modules\aws-api-gateway-cli-test\node_modules\aws-api-gateway-client\dist\apigClient.js:64:57)
at makeRequest (C:\Users\leete\AppData\Roaming\npm-cache\_npx\45824\node_modules\aws-api-gateway-cli-test\index.js:159:38)
at C:\Users\leete\AppData\Roaming\npm-cache\_npx\45824\node_modules\aws-api-gateway-cli-test\index.js:152:5
at C:\Users\leete\AppData\Roaming\npm-cache\_npx\45824\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\credentials.js:124:23
at C:\Users\leete\AppData\Roaming\npm-cache\_npx\45824\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\credentials.js:212:15
at processTicksAndRejections (internal/process/task_queues.js:79:11)
Has this issue been raised before and resolved? What could be configured wrong ? I’ve done all the tests in previous chapters and they were successful.
Much obliged.
Leeten
Hi, just found my mistake. I entered the wrong url. thanks. I can move on now.
Leeten
This solution worked for me, with some tweaking. I’ve posted my working code (with different values) below, hope this messy command helps somebody. Note that the space in hello world had to be filled in, and the double quotes are escaped.
npx aws-api-gateway-cli-test --username admin@example.com --password Passw0rd! --user-pool-id us-east-2_12345123 --app-client-id 6912345123451234512345 --cognito-region us-east-2 --identity-pool-id us-east-2:12341234-d614-4a0b-9318-1234512345 --invoke-url https://1234512345.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\"}
I got an TypeError when running the command to test the API. I’ve gotten along successfully until this point. I’ve triple checked the values are correct. It looks like I’m able to get credentials but then it throws an error when attempting to ping the API.
System:
node: v15.0.0
npm: 7.3.0
Full Error:
Authenticating with User Pool
Getting temporary credentials
Making API request
/Users/paulgerhartz/.npm/_npx/ea84c6478cf14779/node_modules/aws-api-gateway-cli-test/index.js:172
if (argv.body.startsWith("@")) {
^
TypeError: argv.body.startsWith is not a function
at makeRequest (/Users/paulgerhartz/.npm/_npx/ea84c6478cf14779/node_modules/aws-api-gateway-cli-test/index.js:172:17)
at /Users/paulgerhartz/.npm/_npx/ea84c6478cf14779/node_modules/aws-api-gateway-cli-test/index.js:152:5
at /Users/paulgerhartz/.npm/_npx/ea84c6478cf14779/node_modules/aws-sdk/lib/credentials.js:124:23
at /Users/paulgerhartz/.npm/_npx/ea84c6478cf14779/node_modules/aws-sdk/lib/credentials.js:212:15
at processTicksAndRejections (node:internal/process/task_queues:75:11)
npm ERR! code 1
npm ERR! path /Users/paulgerhartz/notes-api
npm ERR! command failed
I was receiving the error:
{
status: 500,
statusText: 'Internal Server Error',
data: {
error: 'One or more parameter values were invalid: Type mismatch for key userId expected: S actual: NULL'
}
}
It was related to serverless.yml not having the key/value of
cors: true
create:
handler: create.main
events:
- http:
path: notes
method: post
cors: true // this was missing as it is not in the current documentation https://serverless-stack.com/chapters/secure-the-apis.html
authorizer: aws_iam