Comments for Test the APIs

You might have to login to your AWS console and the User Pool to see what is going on. I might just create another user and use that?

I skiped this phase and solved the challenge using the front end.

With Cognito when you create a user the first password is temporary and needs to be change at first connexion.

I see. Glad you figured it out.

When testing the API I am continually seeing an error: Missing required arguments: identity-pool-id, invoke-url, path-template zsh: command not found: --identity-pool-id=us-east-2:3139818b-a595-44ae-87b7-1841c3a07fa3

I checked multiple times to ensure that the correct values are being passed. The correct regions are specified. The format is correct - i copy and pasted from the tutorial. I manually typed in --identity-pool-id='us-east-2:3139818b-a595-44ae-87b7-1841c3a07fa3' \ in case there was a character encoding mismatch. What else could be the problem?

--username 'my.email@gmail.com' \
--password='Passw0rd!' \
--user-pool-id='us-east-2_Yqa7o7Dp6' \
--app-client-id='7tnd9tlojl69ktim5la48r1iao' \
--cognito-region='us-east-2' \
--identity-pool-id='us-east-2:3139818b-a595-44ae-87b7-1841c3a07fa3' \
--invoke-url='https://09zogfgfrb.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"}'

The error sounds like it is saying that the command is not in the right format. It thinks that identity-pool-id=us-east-2:3139818b-a595-44ae-87b7-1841c3a07fa3 is the command you are trying to run.

Can you post the full command you are trying to run?

yes it is an issue with power shell and it works on CMD

1 Like

This seems like a basic question but I cant figure out how to console.log in my Lambda function

You can add the console.log just as you would normally. But you need to look at the Lambda logs to see them. You can read up here on how to set them up.

hello, Iā€™m getting this error when running aws-api-gateway-cli-test command

Authenticating with User Pool
Getting temporary credentials
Making API request
{ status: 403,
  statusText: 'Forbidden',
  data: { message: 'Forbidden' } }

Hi. I am totally new to aws and I find this tutorial very good for people like me. I have passed the local function invokes with not much problem but now I am facing 502 Bad Gateway error now. Lambda function test result is as follows:

{
  "errorMessage": "Cannot find module 'babel-runtime/regenerator'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._load (module.js:474:25)",
    "Module.require (module.js:596:17)",
    "require (internal/module.js:11:18)",
    "Object.<anonymous> (/var/task/create.js:97:18)",
    "__webpack_require__ (/var/task/create.js:20:30)",
    "Object.<anonymous> (/var/task/create.js:193:20)",
    "__webpack_require__ (/var/task/create.js:20:30)",
    "/var/task/create.js:84:18",
    "Object.<anonymous> (/var/task/create.js:87:10)"
  ]
}

cmd is as follows:

npx aws-api-gateway-cli-test --username example@xxx.com --password Passw0rd! --user-pool-id us-west-2_xxxxxxxxx --app-client-id xxxxxxxxxxxxxxxx --cognito-region us-west-2 --identity-pool-id us-west-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --invoke-url https://omn153eoy1.execute-api.us-west-2.amazonaws.com/prod --api-gateway-region us-west-2 --path-template /notes --method POST --body "{\"content\":\"hello again\",\"attachment\":\"hi.jpg\"}"

I would really appreciate if anyone could help me out with this error. Thanks in advance. :grinning:

This is my repository

https://github.com/BabyYawLwi/serverless_test1

Do you get that error that you posted when you run the test command or is that error coming from the Lambda logs?

Can you check the API Gateway or Lambda logs?

Struggled for an embarrassingly long time in trying to solve this, and finally came across your reply. Thank you kind person!

1 Like

@nmahurin glad someone found it useful

1 Like

Hi, I had a similar problem to someone else but canā€™t find it here anymore.

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

I am using the right URL and double-checked everything.

Thank you in advance for any advice.

Hi, I get the below error whenever I run the command.
Authenticating with User Pool Getting temporary credentials Making API request { status: 404, statusText: 'Not Found', data: { message: 'No method found matching route / for http method POST.' } }

This is my command I run:
npx aws-api-gateway-cli-test --username='test@t.com' --password='Admin123!' --user-pool-id='us-east-1_n2u1yS41s' --app-client-id='1lmq66tkudd4ajiak3vhginpam' --cognito-region='us-east-1' --identity-pool-id='us-east-1:0d942a90-e09a-4bbe-96be-5df6436c813f' --invoke-url='https://1d2k7e1xkf.execute-api.us-east-1.amazonaws.com/prod' --api-gateway-region='us-east-1' --path-template= '/notes' --method='POST' --body='{"content":"hello world","attachment":"hello.jpg"}'

Iā€™ve cross checked my credentials x2
Thank you in advanceā€¦

This error sounds like your API doesnā€™t have a POST method for that route? Can you make sure that you are able to test that using serverless invoke local before testing it through API Gateway?

This usually happens if the command is not formatted correctly. Can you make sure the quotes around those parameters are set correctly? If you copied it from the PDF it can sometimes be incorrect.

Invalid UserPoolId format.

As stated before Windows shell dislikes the quoting. I didnā€™t see a solution, so sorry if this is already posted. The following quoting & escape scheme will work on Windows.

npx aws-api-gateway-cli-test --username="user@domain.net" --password="Passw0rd!" --user-pool-id="us-east-2_xxxxxxxxx" --app-client-id="xxxxxxxxxxxxxxxxxxxxxxxxx" --cognito-region="us-east-2" --identity-pool-id="us-east-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --invoke-url="https://xxxxxxxxxx.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\"}"
2 Likes