# Test the Configured APIs

**URL:** <https://discourse.sst.dev/t/test-the-configured-apis/179>\
**Category:** Chapter Comments\
**Created:** [May 9, 2018, 11:20pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179 "2018-05-09T23:20:41Z")\
**Posts on this page:** 15\
**Page:** 3

<div class="post-metadata">

**Author:** ![granto](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/granto/32/764_2.png) [@granto](https://discourse.sst.dev/u/granto)\
**Post date:** [February 25, 2020, 3:56am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/46 "2020-02-25T03:56:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [March 8, 2020, 8:07pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/47 "2020-03-08T20:07:58Z")

</div>

Glad you figured it out.

---

<div class="post-metadata">

**Author:** ![markgargan](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/markgargan/32/903_2.png) [@markgargan](https://discourse.sst.dev/u/markgargan)\
**Post date:** [June 29, 2020, 10:37pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/48 "2020-06-29T22:37:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leetenc](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@leetenc](https://discourse.sst.dev/u/leetenc)\
**Post date:** [November 3, 2020, 10:45pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/50 "2020-11-03T22:45:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leetenc](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@leetenc](https://discourse.sst.dev/u/leetenc)\
**Post date:** [November 3, 2020, 11:17pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/51 "2020-11-03T23:17:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [November 13, 2020, 6:22pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/52 "2020-11-13T18:22:06Z")

</div>

Glad you figured it out!

---

<div class="post-metadata">

**Author:** ![core50](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@core50](https://discourse.sst.dev/u/core50)\
**Post date:** [November 26, 2020, 10:37am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/53 "2020-11-26T10:37:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![agarwri](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/agarwri/32/1040_2.png) [@agarwri](https://discourse.sst.dev/u/agarwri)\
**Post date:** [December 2, 2020, 8:19pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/54 "2020-12-02T20:19:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sunilvb](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/sunilvb/32/1041_2.png) [@sunilvb](https://discourse.sst.dev/u/sunilvb)\
**Post date:** [December 5, 2020, 1:48pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/55 "2020-12-05T13:48:16Z")

</div>

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/_/_/\*”

---

<div class="post-metadata">

**Author:** ![adieCodes](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/adiecodes/32/1044_2.png) [@adieCodes](https://discourse.sst.dev/u/adieCodes)\
**Post date:** [January 7, 2021, 11:48am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/56 "2021-01-07T11:48:03Z")

</div>

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](https://bmrv7h8aj6.execute-api.us-east-1.amazonaws.com/dev)):

```auto
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.

 ![Screenshot 2021-01-07 at 11.47.30](https://canada1.discourse-cdn.com/flex032/uploads/serverless_stack/original/2X/8/8b95b0effd566b4956e0b348ec973dbb2c6403b4.png)

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](https://github.com/adieCodes/serverless-stack-api)

---

<div class="post-metadata">

**Author:** ![adieCodes](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/adiecodes/32/1044_2.png) [@adieCodes](https://discourse.sst.dev/u/adieCodes)\
**Post date:** [January 10, 2021, 9:33am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/57 "2021-01-10T09:33:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kevin07696](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/kevin07696/32/1122_2.png) [@kevin07696](https://discourse.sst.dev/u/kevin07696)\
**Post date:** [February 6, 2021, 2:02am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/58 "2021-02-06T02:02:12Z")

</div>

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'
  }
}
```

---

<div class="post-metadata">

**Author:** ![kevin07696](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/kevin07696/32/1122_2.png) [@kevin07696](https://discourse.sst.dev/u/kevin07696)\
**Post date:** [February 6, 2021, 4:48pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/60 "2021-02-06T16:48:48Z")

</div>

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"),
    });
  }
}
```

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [May 15, 2021, 10:43pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/61 "2021-05-15T22:43:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tris-909](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/tris-909/32/1189_2.png) [@Tris-909](https://discourse.sst.dev/u/Tris-909)\
**Post date:** [June 26, 2021, 10:59am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/62 "2021-06-26T10:59:56Z")

</div>

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

[Previous page](https://discourse.sst.dev/t/test-the-configured-apis/179.md?page=2)
