Comments for Test the APIs

Hey Angququ,

It’s fine to have it has food4thought.
Do you mind posting your github repo link?

Also is your region Ohio? (If you look at the top right corner in your aws console)

Hi, thanks for such timely replies, I really appreciate this.

Yes, my region for AWS states Ohio but I’m working within the us-east-2 / N. California one. Is this where my issue is coming from?
image

Also, here’s my github repo!

Hey Angququ,
I’m going to PM you instead. I don’t want to blow up this particular thread with just troubleshooting steps specific to your issue.

2 Likes

Hi everyone! I still need help on my issue, so if you have any advice, I’d be happy to hear / try it!

Hi there, do you mind reposting what the exact issue is that you are having?

I keep getting the error USER_SRP_AUTH is not enabled for the client. If I do Enable SRP (secure remote password) protocol based authentication (ALLOW_USER_SRP_AUTH) in the app client, I get the error Unable to verify secret hash for client 55tcevag... (where 55tcevag… is my app client id). I think this relates to this comment in Create a Cognito User Pool, where it seems that AWS made some changes to the settings which outdated the documentation. Below you’ll find a screenshot of my current app client settings. I’m not sure whether I should still enable SRP and/or disable the first option, but creating users from the command line also fails. Any thoughts?

1 Like

I ran into the same problem. Was able to solve it with the following settings:

1 Like

We recently updated the guide with this. There was a change in the AWS Console.

I’m having the same issue, did you resolve it ?

I’m having an issue where my body object is not being processed.

My body flag is: --body='{"content":"hello test","attachment":"hello-test.jpg"}'

but I get the following response (removed userID):

{ status: 200,
  statusText: 'OK',
  data:
   { userId: 'UserID',
     noteId: '04627170-451d-11ea-a651-958c37f77029',
     createdAt: 1580580151815 } 
}

I get an entry in my DynamoDB table and my code is exact to the tutorial.

My CloudWatch logs reveals:

  • Method request body before transformations:
{
    "content": "hello test",
    "attachment": "hello-test.jpg"
}
  • the create function in invoked, but then logs
  • (I removed the userID) Endpoint response body before transformations:
{
{
    "statusCode": 200,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    },
    "body": "{\"userId\":\"USERID\",\"noteId\":\"04627170-451d-11ea-a651-958c37f77029\",\"createdAt\":1580580151815}"
}

Not sure why my body json won’t get processed. Any ideas?

I’ve resolved it, insted of “” put ‘’

“{“content”:“hello world”,“attachment”:“hello.jpg”}”

‘{“content”:“hello world”,“attachment”:“hello.jpg”}’

1 Like

Thanks for replying…I used the single quotes around the cli command, the double quotes you see is what I copied from CloudWatch logs

I am experiencing a similar issue discussed before, but I did not seem to find a solution here. I am receiving this message:

{ status: 403,
  statusText: 'Forbidden',
  data:
   { message: 'Credential should be scoped to a valid region, not \'us-east-1\'. ' } }

My cli command is as follows:

npx aws-api-gateway-cli-test --username='admin@example.com' --password='Somepassword' --user-pool-id='us-east-2_XXXXXX' --app-client-id='xxxxxxxxxxxxxxxxx' --cognito-region='us-east-2' --identity-pool-id='us-east-2:xxxxxxx-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"}'

I’ve double checked everything on AWS and ensured it was set to us-east-2. I even checked my default settings in .aws

Maybe I am missing something obvious but I’ve quadruple checked everything and at a loss what is off.

okay, so after posting the markdown it was painfully obvious to me that I was missing the ‘–’ before 'api-gateway-region.

:man_facepalming:

Are you still having issues? Can you console.log inside your Lambda function to see whats going on?

For anyone else having this error:

{
  status: 502,
  statusText: 'Bad Gateway',
  data: { message: 'Internal server error' }
}

One possible solution is to escape the string at the body option

Yes!

I’m consoling out data & params.Items in create.js but nothing shows up in my CloudWatch logs for the /aws/lambda/notes-app-api-dev-create lambda & my gateway logs are the same as I posted before.

First I would make sure that your create functions are actually getting called. If they are, then I would find the spot where it is failing.

From your description it sounds like it’s not getting called at all?

@jayair

Test the API

npx aws-api-gateway-cli-test \
--username='admin@example.com' \
--password='Passw0rd!' \
--user-pool-id='YOUR_DEV_COGNITO_USER_POOL_ID' \
--app-client-id='YOUR_DEV_COGNITO_APP_CLIENT_ID' \
--cognito-region='YOUR_DEV_COGNITO_REGION' \
--identity-pool-id='YOUR_DEV_IDENTITY_POOL_ID' \
--invoke-url='YOUR_DEV_API_GATEWAY_URL' \
--api-gateway-region='YOUR_DEV_API_GATEWAY_REGION' \
--path-template='/notes' \
--method='POST' \
--body='{"content":"hello world","attachment":"hello.jpg"}'

To make the above command work in Windows Command Prompt, remove the =, \, ’ and have the command in a single line else they will be read as multiple commands. --body message should be as shown in the sample below:

npx aws-api-gateway-cli-test --username [admin@example.com](mailto:admin@example.com) --password  Passw0rd! --user-pool-id YOUR_DEV_COGNITO_USER_POOL_ID --app-client-id YOUR_DEV_COGNITO_APP_CLIENT_ID --cognito-region  YOUR_DEV_COGNITO_REGION --identity-pool-id  YOUR_DEV_IDENTITY_POOL_ID --invoke-url YOUR_DEV_API_GATEWAY_URL --api-gateway-region  YOUR_DEV_API_GATEWAY_REGION --path-template  /notes --method  POST --body **"{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}"**

In Windows PowerShell, the difference is in --body (Double quotes is typed twice. That is one way the command works in PowerShell):

npx aws-api-gateway-cli-test --username [admin@example.com](mailto:admin@example.com) --password Passw0rd! --user-pool-id YOUR_DEV_COGNITO_USER_POOL_ID --app-client-id YOUR_DEV_COGNITO_APP_CLIENT_ID --cognito-region YOUR_DEV_COGNITO_REGION --identity-pool-id YOUR_DEV_IDENTITY_POOL_ID --invoke-url YOUR_DEV_API_GATEWAY_URL --path-template /notes --method POST --body **'{""content"":""hello world"",""attachment"":""hello.jpg""}'**
2 Likes

Thank you so much for sharing this :pray:t5: