Comments for Test the APIs

I think for the error you are referring to, it was probably telling you that you don’t have access to a certain AWS resource. So it is most likely related to how you have the permissions setup.

I call this command in Ubuntu18.04.

npx aws-api-gateway-cli-test --username='xxxx@xxx.co.jp' --password='zzzzzz' --user-pool-id='ap-northeast-1_oUGy3xW9F' --app-client-id='4jpd2k411futv4a6oa3eibg08f' --cognito-region='ap-northeast-1' --identity-pool-id='ap-northeast-1:1e66a557-a647-4249-9a65-1cc0dd0dd681' --invoke-url='https://gbyvpj7pd5.execute-api.ap-northeast-1.amazonaws.com/prod' --api-gateway-region='ap-northeast-1' --path-template='/notes' --method='POST' 

I looked this error in bash

Authenticating with User Pool
Getting temporary credentials
Making API request
{ status: 502,
  statusText: 'Bad Gateway',
  data: { message: 'Internal server error' } }

cloudwatch has this error

{ "errorMessage": "Cannot read property 'content' of null", "errorType": "TypeError", "stackTrace": [ "_callee$ (/var/task/webpack:/create.js:12:27)", "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)", "/var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14", "new Promise (<anonymous>)", "new F (/var/task/node_modules/core-js/library/modules/_export.js:35:28)", "/var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12", "main (/var/task/create.js:259:21)" ] }

Not why successful?,I would like to know reasons. If I give you some config, I tell you my config.

Hmm Can you confirm that the serverless invoke local command in this chapter - https://serverless-stack.com/chapters/add-a-create-note-api.html worked for you?

For anyone else debugging, I’m on Mac OS, I added AdministratorAccess to my CognitoXXXAuth_Role and it allowed me access.

My error was:

Making API request
{ status: 403,
  statusText: 'Forbidden',
  data:
   { Message: 'User: arn:aws:sts::**_12-Digit-NumberXXX_**:assumed-role/Cognito_**_My-Bucket-_** Auth_Role/CognitoIdentityCredentials is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-east-2: **_12-Digit-NumberXXX_** :**_My-URL-_** /prod/POST/posts' } }

I will update when I discover what was wrong with my IAM permission.

I got Internal 500 Server Error and for me it turns out that my DynamoDB region was wrong in serverless.yml … from the tutorial it is us-east-1 but looking at my AWS console DynamoDB the ARN references us-west-2 … so that fixed it.

Thanks! Let me know when you figure it out.

Yeah we just updated the tutorial with the fix. Thanks for reporting it.

Bad Gateway error

npx aws-api-gateway-cli-test --username='admin@example.com' \
--password='Passw0rd!' \
--user-pool-id='us-west-2_xxxx' \
--app-client-id='1u7ltio1qqo2q46qn64ocgvhnc' \
--cognito-region='us-west-2' \
--identity-pool-id='us-west-2:xxxx' \
--invoke-url='https://7ra01185zk.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"}'
Authenticating with User Pool
Getting temporary credentials
Making API request
{ status: 502,
  statusText: 'Bad Gateway',
  data: { message: 'Internal server error' } }

I tried to look in CloudWatch log but I couldn’t find the root cause.

I confirmed that the serverless invoke local --function create --path mocks/create-event.json works.

Appreciate any pointers to resolve this issue.

Hmm usually a 502 error is related to our code throwing an error. Did the Lambda or API Gateway logs not show anything at all?

@jayair: Thanks for your response.

Since I couldn’t figure out the issue, I cleaned up my notes-app environment and restarted from beginning. I haven’t reached Test the APIs chapter yet. But, if I encounter 502 error again, I would update it here. Thanks, again!

1 Like

Thank you! Your solution worked for me.

1 Like

Hello, I was wondering if someone could help me please?

I’m getting the same error as a previous post did, my error is:

npx: installed 105 in 26.954s

Authenticating with User Pool

Getting temporary credentials

Token is not from a supported provider of this identity pool.

The user solved their issue by saying “the user pool id was not configured properly” but I’m not sure what I need to do to configure it correctly. I did have an issue before where my user wasn’t confirmed but found out I could just confirm in the AWS console, so I sorted that error but can’t figure this one out.

Any help would be greatly appreciated.

Kind regards

Steve

I have the same error.

CloudWatch has this error:

module initialization error: ReferenceError

the console says it’s a 502 Bad gateway error

serverless version is 1.30.1
node is 8.9.4
npm is 6.1.0

The local commands work

@danieloi That sounds like an error in your code. What is the full error from CloudWatch?

@StephenDRoberts Hmm this error sounds like it the Identity Pool is not configured to use this User Pool? When you created your Identity Pool in this chapter (https://serverless-stack.com/chapters/create-a-cognito-identity-pool.html) did you use the right User Pool ids?

@jayair That’s the error I got from cloudwatch

Yeah but is that the full error? Can you paste the whole error here?

I have been receiving the 500 error and so I checked the policy simulator.
I did get access denied for the API gateway but the policy is exactly the same one as the tutorial. Can anyone think of why this would be happened?

You can check out this chapter where we debug it using the simulator - https://serverless-stack.com/chapters/debugging-serverless-api-issues.html

Hello there, I really appreciate the effort that was made to create such a well written tutorial! Here is some background info on my issue. I was getting the following:

Authenticating with User Pool
Getting temporary credentials
Token is not from a supported provider of this identity pool.

I deleted my cognito Identity Pool and created a new one. That fixed the problem. Now I’m receiving the following error:

Authenticating with User Pool
Getting temporary credentials
Making API request
getaddrinfo ENOTFOUND ly55wbovq4.execute-api.us-east-1.amazonaws.com:443

I went through the tutorial again to double check that everything was correct. When I copied and pasted the error into google this link suggests that it’s a DNS problem … I doubt that is the case but that’s everything that I know. What does this mean?

Yeah that is usually a connectivity issue. Can you post the entire command that you are using?