Comments for Test the APIs

Hi Jay,
Thank you for responding, yes I did test locally. So I re did the tutorial from start. But now I get this error

Authenticating with User Pool
Getting temporary credentials

Making API request

getaddrinfo ENOTFOUND 1d2k7e1xkf.execute-api.us-east-1.amazonaws.com 1d2k7e1xkf.execute-api.us-east-1.amazonaws.com:443

Totally lost at this point…

This error seems more like a network issue. Just make sure you have access to that domain.

Thanks for posting this!

Hello I keep getting the following message

bash: --invoke-url=https://ghk4wyai1b.execute-api.us-east-2.amazonaws.com/prod: No such file or directory

When I run

npx aws-api-gateway-cli-test \
> > --username='admin@example.com' \
> > --password='Passw0rd!' \
> > --user-pool-id='us-east-2_rTqoSIqQc' \
> > --app-client-id='3da48ufo9nvn3a26c1nsilt6r3' \
> > --cognito-region='us-east-2' \
> > --identity-pool-id='us-east-2:32c70d8c-c23f-4a34-a9e3-6c39ebf07e97' \
> > --invoke-url='https://ghk4wyai1b.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"}'

And this is what my service information looks like
Service Information

service: notes-app-api

stage: prod

region: us-east-2

stack: notes-app-api-prod

resources: 35

api keys:

None

endpoints:

POST - https://ghk4wyai1b.execute-api.us-east-2.amazonaws.com/prod/notes

functions:

create: notes-app-api-prod-create

get: notes-app-api-prod-get

list: notes-app-api-prod-list

update: notes-app-api-prod-update

delete: notes-app-api-prod-delete

layers:

None

I really don’t know what I’m doing wrong.

Thanks,

These errors are usually related to the CLI command not being formatted correctly. Can you paste the exact command you are using?

Thanks I actually went back and remade my user pool and app client, and it worked.

I am getting the status 403 error

Making API request
{ status: 403,
  statusText: 'Forbidden',
  data: { message: 'Forbidden' } }
  1. have deleted and recreated by identity pool
  2. attached administrator policy to Cognito roles

Any other ideas?

Hmmm you might want to take a look at this chapter to debug this. Specifically using the Policy Simulator.

How do you format the path-template to test the other methods?

What do you mean by other methods? The other API endpoints?

Yes, I just ended up using Postman because I was testing an unAuth role.

1 Like

Greeting to you all, after deploying my API’s when trying to test them i get this
error

I have gone through the Debugging Serverless API Issues section and get this error when invoking the APIs

ive also just attached my repo too https://github.com/BrandonDlamini/notes-app-api

In my case , the username is not the email but the username created when signup.Run this command to get the username ->

aws cognito-idp admin-get-user --user-pool-id youruserpoolid --username youremail  --region yourregion

and you should receive a json file that contain the correct username to authenticate.
Here is the documentation of the command

{
**"Username": "your this code as your username",
"Enabled": true,
"UserStatus": "CONFIRMED",
"UserCreateDate": 1564676437.656,
"UserAttributes": [
{
"Name": "sub",
"Value": "65cb73f5-eb0d-4adf-a9d0-39c57dd2f684"
},
{
"Name": "email_verified",
"Value": "false"
},
{
"Name": "email",
"Value": "your@email *** this is no the one ***"
}
],
"UserLastModifiedDate": 1564676585.375
}

Hmm that IAM test shouldn’t fail. I don’t think there is anything wrong with your code. Make sure the role is setup properly.

How do i set up the role correctly ?

@jayair How do i set up the role correctly, if i may ask ?

It’s really hard to tell what is causing the problem here. Most people end up re-doing the chapter to setup the IAM role again.

But you need to make sure the Policy Simulator works.

Hello guys, I struggled for 2 hours with the error: User ******** is not authorized to perform: execute-api:Invoke on resource: ********

Then I realized the “Edit Policy Document” part at https://serverless-stack.com/chapters/create-a-cognito-identity-pool.html didn’t applied (real bug not a mistake as I tried to create a new identity pool and it didn’t applied either)

So I needed to go to IAM > Roles > Cognito_notesidentitypoolAuth_Role
Expand the Policy item > Edit Policy > JSON then paste your JSON + validate and voilà the command is now successful !

2 Likes

Hello, I have an error while running this command:

$ npx aws-api-gateway-cli-test \
--username='admin@example.com' \
--password='Passw0rd!' \
--user-pool-id='YOUR_COGNITO_USER_POOL_ID' \
--app-client-id='YOUR_COGNITO_APP_CLIENT_ID' \
--cognito-region='YOUR_COGNITO_REGION' \
--identity-pool-id='YOUR_IDENTITY_POOL_ID' \
--invoke-url='YOUR_API_GATEWAY_URL' \
--api-gateway-region='YOUR_API_GATEWAY_REGION' \
--path-template='/notes' \
--method='POST' \
--body='{"content":"hello world","attachment":"hello.jpg"}'

This is my output from the command:
npx: installed 106 in 10.792s
Authenticating with User Poo.
Getting temporary credentials
Invalid identity pool configuration. Check assigned IAM roles for this pool.

There’s no result code so I’m unable to debug based on the code. One thing I noticed that’s different from the screenshots provided by the guide is an extra warning message in the Indentity Pool dashboard:

Could this be the reason?

Hi there after scouring the internet for solutions a friend of mines helped me realize that I should install the APIG test globally and this solved my 403 forbidden error. when I try run the command locally using

**npx aws-api-gateway-cli-test** i get the 403 error but when I install the test globally i get a 200 response