# 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:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![dsherida](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/dsherida/32/264_2.png) [@dsherida](https://discourse.sst.dev/u/dsherida)\
**Post date:** [October 6, 2018, 6:59pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/21 "2018-10-06T18:59:01Z")

</div>

When trying to run the `aws-api-gateway-cli-test` command, I get the following error:

> Authenticating with User Pool  
> Getting temporary credentials  
> Making API request  
> /usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-sdk/lib/request.js:31  
> throw err;  
> ^
> 
> TypeError: Cannot read property ‘1’ of null  
> at Object.apigClientFactory.newClient (/usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-api-gateway-client/dist/apigClient.js:63:57)  
> at makeRequest (/usr/local/lib/node\_modules/aws-api-gateway-cli-test/index.js:157:38)  
> at /usr/local/lib/node\_modules/aws-api-gateway-cli-test/index.js:150:5  
> at /usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-sdk/lib/credentials.js:123:23  
> at Response. (/usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-sdk/lib/credentials/cognito\_identity\_credentials.js:258:7)  
> at Request. (/usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-sdk/lib/request.js:364:18)  
> at Request.callListeners (/usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-sdk/lib/sequential\_executor.js:109:20)  
> at Request.emit (/usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-sdk/lib/sequential\_executor.js:81:10)  
> at Request.emit (/usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-sdk/lib/request.js:683:14)  
> at Request.transition (/usr/local/lib/node\_modules/aws-api-gateway-cli-test/node\_modules/aws-sdk/lib/request.js:22:10)

---

<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:** [October 7, 2018, 12:01am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/22 "2018-10-07T00:01:19Z")

</div>

Can I see the full command you are running?

---

<div class="post-metadata">

**Author:** ![dsherida](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/dsherida/32/264_2.png) [@dsherida](https://discourse.sst.dev/u/dsherida)\
**Post date:** [October 7, 2018, 2:02am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/23 "2018-10-07T02:02:26Z")

</div>

```
npx aws-api-gateway-cli-test \
  --username='admin@example.com' \
  --password='Passw0rd!' \
  --user-pool-id='us-east-1_TvDTXmJUy' \
  --app-client-id='6stng9a2077jii9o3j36bslb4l' \
  --cognito-region='us-east-1' \
  --identity-pool-id='us-east-1:a52ef563-b9a4-4d69-bc38-60f140987bf2' \
  --invoke-url='api.crisispaintball.com/dev' \
  --api-gateway-region='us-east-1' \
  --path-template='/notes' \
  --method='POST' \
  --body='{"content":"hello world","attachment":"hello.jpg"}'
```

---

<div class="post-metadata">

**Author:** ![dsherida](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/dsherida/32/264_2.png) [@dsherida](https://discourse.sst.dev/u/dsherida)\
**Post date:** [October 7, 2018, 2:04am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/24 "2018-10-07T02:04:45Z")

</div>

I’m also getting the message: `Error: Request failed with status code 500`, when I build the React app for dev, run it locally, and try to do anything in the Notes app that requires an API call (ie. create a new note).

I’m not sure where the best place to post this issue would be, so if you point me in the right direction I can move this comment.

---

<div class="post-metadata">

**Author:** ![dsherida](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/dsherida/32/264_2.png) [@dsherida](https://discourse.sst.dev/u/dsherida)\
**Post date:** [October 7, 2018, 7:41pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/25 "2018-10-07T19:41:24Z")

</div>

I resolved my status code 500 issue by making the changes found here:

> <https://github.com/AnomalyInnovations/serverless-stack-com/commit/3b92d510ec6a2c584cfed7239f6d3e13a510502e#diff-840d24d57883fc15e1356fa07c9df8b4>

---

<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:** [October 8, 2018, 8:25pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/26 "2018-10-08T20:25:52Z")

</div>

Oh I’m glad that helped you out!

---

<div class="post-metadata">

**Author:** ![bwsolutions](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/bwsolutions/32/305_2.png) [@bwsolutions](https://discourse.sst.dev/u/bwsolutions)\
**Post date:** [October 12, 2018, 3:30am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/27 "2018-10-12T03:30:34Z")

</div>

I am get a 403 error when I try to test the api-gateway.

> $ npx aws-api-gateway-cli-test   
> –username=‘admin@example.com’   
> –password=‘Passw0rd!’   
> –user-pool-id=‘us-east-1\_8uPZvWNTi’   
> –app-client-id=‘176k27ktpjb7b4md1s1rifneei’   
> –cognito-region=‘us-east-1’   
> –identity-pool-id=‘us-east-1:9c80f142-cb02-40ed-9b49-593104e4158d’   
> –invoke-url=“[https://uqlien7vub.execute-api.us-east-1.amazonaws.com/dev](https://uqlien7vub.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”}’
> 
> npx: installed 105 in 33.656s  
> Authenticating with User Pool  
> Getting temporary credentials  
> Making API request  
> { status: 403,  
> statusText: ‘Forbidden’,  
> data: { message: ‘Forbidden’ } }

I just started with Part II of the App and got to this part and can not get it to work. I have enabled logs and nothing shows up in any cloudwatch logs. I tested the api in the policy simulator and that worked. and Seed does not show any messages when I enable the logs.  
Any suggestions on other things to test?

> **[GitHub - bwsprojects/serverless-stack-2-api: sample app using aws and react...](https://github.com/bwsprojects/serverless-stack-2-api)**
>
> sample app using aws and react js and serverless framework - GitHub - bwsprojects/serverless-stack-2-api: sample app using aws and react js and serverless framework

thanks,  
bill

---

<div class="post-metadata">

**Author:** ![bwsolutions](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/bwsolutions/32/305_2.png) [@bwsolutions](https://discourse.sst.dev/u/bwsolutions)\
**Post date:** [October 13, 2018, 8:50pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/28 "2018-10-13T20:50:41Z")

</div>

This is for anyone that may be using a Windows 10 system and having problems with 403 errors…

After many hours of testing, checking, etc and finally making a minor edit to apig-test to dump the entire “response” from the API Request when there is an error, I finally got this to work.  
I am not 100% sure WHY it works, but it is probably Windows 10 and the shell I am using…

To start, I had all kinds of problems getting either the Command shell or powershell on windows 10 to accept all the parameters. I tried many attempts to escape the quotes and never got the command to work.  
So I used Git Bash. It was easy to edit the line in notepad then paste into git bash and the command executed.

However, I was getting the 403 error. I double checked all the roles, policies, etc and they were correct.

So when I got apig-test to display the entire response message I found something strange…  
in the headers that was sent to AWS is

> POST /dev/C:/Program%20Files/Git/notes HTTP/1.1…

Where is the **“C:/Program%20Files/Git/”** coming from??? It is not in the command line.  
To make an already long story shorter…  
I fixed the problem by making a very simple change to the command line…

Before

> –invoke-url=“[https://uqlien7vub.execute-api.us-east-1.amazonaws.com/dev”](https://uqlien7vub.execute-api.us-east-1.amazonaws.com/dev%E2%80%9D)  
> –path-template=’/notes’

After these simple edits to the URL to add trailing / and to path-template to remove leading /

> –invoke-url=“[https://uqlien7vub.execute-api.us-east-1.amazonaws.com/dev/”](https://uqlien7vub.execute-api.us-east-1.amazonaws.com/dev/%E2%80%9D)  
> –path-template=’notes’

IT WORKED!!! ??? !!!

If someone can explain this, I would love to know…  
In the mean time, I am pressing on with this awesome tutorial.  
Hopefully someone finds this helpful.

---

<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:** [October 14, 2018, 5:12pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/29 "2018-10-14T17:12:41Z")

</div>

That’s really weird. Not sure what is going on there. But thanks for the detailed write-up. I’m sure it’ll help other Windows users.

---

<div class="post-metadata">

**Author:** ![HannahStahl](https://avatars.discourse-cdn.com/v4/letter/h/ed655f/32.png) [@HannahStahl](https://discourse.sst.dev/u/HannahStahl)\
**Post date:** [December 5, 2018, 3:00pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/30 "2018-12-05T15:00:18Z")

</div>

I have run the following npx command on dev:

```
npx aws-api-gateway-cli-test \
--username='admin@example.com' \
--password='Passw0rd!' \
--user-pool-id='us-east-1_fZ3XofyFi' \
--app-client-id='2embh2inkauuieqtbll9uisk62' \
--cognito-region=‘us-east-1’ \
--identity-pool-id='us-east-1:2a9a76ff-e661-4ed2-b1a1-17434326dfa3' \
--invoke-url='https://2bbhwgva13.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"}'

```

…and get the following error:

```
npx: installed 105 in 4.695s
Authenticating with User Pool
Getting temporary credentials
Inaccessible host: `cognito-identity.xn--us-east-1-499dua.amazonaws.com'. This service may not be available in the `‘us-east-1’' region.
```

---

<div class="post-metadata">

**Author:** ![HannahStahl](https://avatars.discourse-cdn.com/v4/letter/h/ed655f/32.png) [@HannahStahl](https://discourse.sst.dev/u/HannahStahl)\
**Post date:** [December 5, 2018, 3:04pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/31 "2018-12-05T15:04:13Z")

</div>

Update: I had copied and pasted the command from the tutorial instructions, and for some reason the apostrophes around the ‘us-east-1’ were different than all the other normal apostrophes. I fixed them, and now it works.

---

<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:** [December 7, 2018, 12:11am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/32 "2018-12-07T00:11:28Z")

</div>

Thanks for reporting back. Yeah the copy-paste from the PDF is not great. Try using the web version if you can.

---

<div class="post-metadata">

**Author:** ![g-crow](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/g-crow/32/694_2.png) [@g-crow](https://discourse.sst.dev/u/g-crow)\
**Post date:** [December 4, 2019, 1:18pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/36 "2019-12-04T13:18:56Z")

</div>

I’m stuck on a 500 error… can anyone help?

Here’s the error logged in Seed for my /create lambda:

 ![24 AM](https://canada1.discourse-cdn.com/flex032/uploads/serverless_stack/original/1X/8c16fd21476f5f276aa9501dd2a6b75a4db52d04.png)

It looks It like the table name attempting to be updated is “notes,” where it should be “dev-notes.”

When I tested with the tableName hard-coded in the serverless.yml, it worked fine… solved my own problem, guys. I’d skimmed over the part in the tutorial about replacing the tableName variable under the environment block. Doh! Leaving this post here, in case anyone else runs into the same issue.

---

<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:** [December 16, 2019, 1:25am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/38 "2019-12-16T01:25:54Z")

</div>

Glad you figured it out. Thanks for reporting back.

---

<div class="post-metadata">

**Author:** ![mathewgries](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/mathewgries/32/419_2.png) [@mathewgries](https://discourse.sst.dev/u/mathewgries)\
**Post date:** [December 17, 2019, 7:44pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/39 "2019-12-17T19:44:02Z")

</div>

Windows users testing the API: Especially if using VS Code or Powershell  
VS Code uses powershell, and it doesn’t seem to like the JSON in the body section

Use a normal windows command prompt when testing the API: run as admin  
And use this syntax. This should work with no problems as long as all your CORS settings are correct: This is for both dev and prod, so update the script accordingly, with your credentials

```auto
npx aws-api-gateway-cli-test --username admin@example.com --password Passw0rd! --user-pool-id us-east-1_xxxxxxxxx --app-client-id xxxxxxxxxxxxxxxxxxxxxxxxx --cognito-region us-east-1 --identity-pool-id us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --invoke-url https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/prod --api-gateway-region us-east-1 --path-template /notes --method POST --body "{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}"

```

---

<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:** [January 12, 2020, 2:56am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/40 "2020-01-12T02:56:45Z")

</div>

Thanks for posting this!

---

<div class="post-metadata">

**Author:** ![chickensoup64](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/chickensoup64/32/679_2.png) [@chickensoup64](https://discourse.sst.dev/u/chickensoup64)\
**Post date:** [January 14, 2020, 12:46pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/41 "2020-01-14T12:46:16Z")

</div>

@bwsolutions thanks for your comments. I got a `403` response then tried moving the leading and trailing `/` as per your instructions and it was successful - returns `200` now. I am also using Git Bash on Windows 10.

---

<div class="post-metadata">

**Author:** ![therodfather](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/therodfather/32/1170_2.png) [@therodfather](https://discourse.sst.dev/u/therodfather)\
**Post date:** [January 15, 2020, 1:19pm UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/42 "2020-01-15T13:19:08Z")

</div>

You sir, are the true MVP. Thanks for this solution, worked like a charm.

---

<div class="post-metadata">

**Author:** ![br3ntor](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/br3ntor/32/974_2.png) [@br3ntor](https://discourse.sst.dev/u/br3ntor)\
**Post date:** [January 25, 2020, 10:09am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/44 "2020-01-25T10:09:58Z")

</div>

This formatting for windows also worked for me, thank you.

---

<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 24, 2020, 5:32am UTC](https://discourse.sst.dev/t/test-the-configured-apis/179/45 "2020-02-24T05:32:13Z")

</div>

I’m having an issue where terminal returns: “npx: installed 105 in 9.913s  
Authenticating with User Pool  
Getting temporary credentials  
Token is not from a supported provider of this identity pool.” Any ideas?

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

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