Test the Configured APIs

It appears to have been an issue with using the wrong App Client ID.

1 Like

Glad you figured it out.

Fair play bwsolutions! This sorted me out as well. Sign him y’all!! :smiley:

1 Like

Hi @dsherida, I’ve got similar error of ā€œTypeError: Cannot read property ā€˜1’ of nullā€ as per your post. Did you get that resolved? If so , how? Thanks in advance.
Leeten

Hi, I found the mistake (not hard given such a long command). the invoke_url was entered incorrectly. Thanks

1 Like

Glad you figured it out!

I have the same issue. what is the solution??
Getting temporary credentials
Making API request
{ status: 403,
statusText: ā€˜Forbidden’,

also using git bash on windows 10, this also worked for me :smiley: thanks a lot.

1 Like

For me it was the policy issue. Try changing the ARN to allow your account or ā€˜Any in this account’ and go from there.
This is what worked for me:
ā€œarn:aws:execute-api:YOUR_API_GATEWAY_REGION:YOUR_ACCOUNT:YOUR_API_GATEWAY_ID///*ā€

1 Like

I’ve completed the automated deployments for the backend but I’m getting a 403 when trying to test the dev api. I’m using the following (although I’ve also used my non-custom domain for the invoke-url - https://bmrv7h8aj6.execute-api.us-east-1.amazonaws.com/dev):

npx aws-api-gateway-cli-test \
--username='admin@example.com' \
--password='Passw0rd!' \
--user-pool-id='us-east-1_wXqUWFHGo' \
--app-client-id='7qvgoon9vp171hqc2f27t6brn2' \
--cognito-region='us-east-1' \
--identity-pool-id='us-east-1:dfd50f42-0c81-4d10-a531-73ac91657f43' \
--invoke-url='https://api.adiecodes.com/dev' \
--api-gateway-region='us-east-1' \
--path-template='/notes' \
--method='POST' \
--body='{"content":"hello world","attachment":"hello.jpg"}'
npx: installed 110 in 8.923s
Authenticating with User Pool
Getting temporary credentials
Making API request
{
  status: 403,
  statusText: 'Forbidden',
  data: {
    Message: 'User: arn:aws:sts::669528630144:assumed-role/dev-notes-infra-cognito-CognitoAuthRoleCognitoDefa-1S5NP9V9QLSR0/CognitoIdentityCredentials is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-east-1:********0144:bmrv7h8aj6/dev/POST/notes'
  }
}

I’ve used the policy simulator and it looks like I’m missing the permission to make requests to the API Gateway.

Can anyone she any light on why the services/resources/cognito-policy.yml isn’t being applied? It’s probably worth noting this was on the root of the project (i.e. outside of services directory) before I deployed via Seed.

You can see my code here

Turns out the policy I had added, cognitive-policy.yml in my serverless app wasn’t nested in the correct directory. Should have been services/notes/resources, I hadn’t put it within /notes. Thanks for taking the time to help

1 Like

Hi, while testing the configured apis, I’ve gotten a 500 status code.

npx aws-api-gateway-cli-test  \ 
--username='admin@example.com'  \
--password='Passw0rd!'  \
--user-pool-id='us-east-1_f8yMlCnPZ'  \
--app-client-id='57dskdenhbn3vtqb4q9daog5uh'  \ 
--cognito-region='us-east-1'  \
--identity-pool-id='us-east-1:b4594e5a-8a21-4be4-b546-b895658c19a8'  \
--invoke-url='https://jdr09m6hf1.execute-api.us-east-1.amazonaws.com/dev'  \
--api-gateway-region='us-east-1'  \
--path-template='/notes'  \
--method='POST'  \
--body='{"content":"hello world","attachment":"hello.jpg"}'
Authenticating with User Pool
Getting temporary credentials
Making API request
{
  status: 500,
  statusText: 'Internal Server Error',
  data: {
    error: 'One or more parameter values were invalid: Missing the key userId in the item'
  }
}

This is my DynamoDB Stack. I have userId here, so I’m confused why it is missing.

import { CfnOutput } from "@aws-cdk/core";
import * as dynamodb from "@aws-cdk/aws-dynamodb";
import * as sst from "@serverless-stack/resources";

export default class DynamoDBStack extends sst.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const app = this.node.root;

    const table = new dynamodb.Table(this, "Table", {
      billingMode: dynamodb.BillingMode.PAY_PER_REQUEST, // Use on-demand billing mode
      sortKey: { name: "noteId", type: dynamodb.AttributeType.STRING },
      partitionKey: { name: "userId", type: dynamodb.AttributeType.STRING },
    });

    // Output values
    new CfnOutput(this, "TableName", {
      value: table.tableName,
      exportName: app.logicalPrefixedName("TableName"),
    });
    new CfnOutput(this, "TableArn", {
      value: table.tableArn,
      exportName: app.logicalPrefixedName("TableArn"),
    });
  }
}

Make sure there isn’t a typo in your Lambda code.

Absolute respect, thank you for saving me from a headache, I create an account just to write this comment :smiley: