# Add a Create Note API

**URL:** <https://discourse.sst.dev/t/add-a-create-note-api/125>\
**Category:** Chapter Comments\
**Created:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125 "2018-05-09T19:44:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/1 "2018-05-09T19:44:26Z")

</div>

_From @jayair on Mon Apr 10 2017 00:59:33 GMT+0000 (UTC)_  
  
Link to chapter - [http://serverless-stack.com/chapters/add-a-create-note-api.html](http://serverless-stack.com/chapters/add-a-create-note-api.html)  
  
_Copied from original issue: [https://github.com/AnomalyInnovations/serverless-stack-com/issues/23](https://github.com/AnomalyInnovations/serverless-stack-com/issues/23)_

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/2 "2018-05-09T19:44:31Z")

</div>

_From @nerdguru on Mon Apr 10 2017 15:01:59 GMT+0000 (UTC)_  
  
The runtime line in the serverless.yml file should read:

runtime: nodejs6.10

Looks like you updated it for the prior page for Serverless 1.10’s support of AWS/Node6 but missed this one. Minor thing but thought you’d want to know.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/3 "2018-05-09T19:44:31Z")

</div>

_From @jayair on Mon Apr 10 2017 17:03:25 GMT+0000 (UTC)_  
  
Oh yeah you’re right. Just fixed it - 87587868b0829ded83cfde2a00e7a5af8f441518

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/4 "2018-05-09T19:44:31Z")

</div>

_From @geirman on Fri Apr 14 2017 23:48:42 GMT+0000 (UTC)_  
  
When testing the code, I’m getting a 500 response. How do I troubleshoot this?  
The only thing I’ve done differently is change all instances of `us-east-1` to `us-east-2` to match values I see in my pool id, pool arn, identity pool id, etc. Seemed like the right thing to do.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/5 "2018-05-09T19:44:31Z")

</div>

_From @jayair on Sat Apr 15 2017 00:00:02 GMT+0000 (UTC)_  
  
@geirman that would be a DynamoDB related error. Can you try printing out the error object in this line - [https://github.com/AnomalyInnovations/serverless-stack-com/blame/master/\_chapters/add-a-create-note-api.md#L56](https://github.com/AnomalyInnovations/serverless-stack-com/blame/master/_chapters/add-a-create-note-api.md#L56)

That should give you a clue.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/6 "2018-05-09T19:44:32Z")

</div>

_From @geirman on Sat Apr 15 2017 05:17:05 GMT+0000 (UTC)_  
  
Thanks, that helped. My problem was naming one of the keys `notesId` instead of `noteId`

> ValidationException: One or more parameter values were invalid: Missing the key notesId in the item

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/7 "2018-05-09T19:44:32Z")

</div>

_From @flocve on Mon Apr 17 2017 10:09:21 GMT+0000 (UTC)_  
  
Hello,  
When I run the command : `serverless webpack invoke --function create --path event.json`  
I have this :

```auto
{ statusCode: 500,
  headers: 
   { 'Access-Control-Allow-Origin': '*',
     'Access-Control-Allow-Credentials': true },
  body: '{"status":false}' }

```

content of DynamoDB object :

```auto
      Config {
        credentials: null,
        credentialProvider: [Object],
        region: 'eu-west-2',
        logger: null,
        apiVersions: {},
        apiVersion: null,
        endpoint: 'dynamodb.eu-west-2.amazonaws.com',
        httpOptions: [Object],
        maxRetries: undefined,
        maxRedirects: 10,
        paramValidation: true,
        sslEnabled: true,
        s3ForcePathStyle: false,
        s3BucketEndpoint: false,
        s3DisableBodySigning: true,
        computeChecksums: true,
        convertResponseTypes: true,
        correctClockSkew: false,
        customUserAgent: null,
        dynamoDbCrc32: true,
        systemClockOffset: 0,
        signatureVersion: 'v4',
        signatureCache: true,
        retryDelayOptions: {},
        useAccelerateEndpoint: false },
     isGlobalEndpoint: false,
     endpoint: 
      Endpoint {
        protocol: 'https:',
        host: 'dynamodb.eu-west-2.amazonaws.com',
        port: 443,
        hostname: 'dynamodb.eu-west-2.amazonaws.com',
        pathname: '/',
        path: '/',
        href: 'https://dynamodb.eu-west-2.amazonaws.com/' },
     _clientId: 1 },
  attrValue: 'S8' }

```

And the error is :

```auto
 CredentialsError: Missing credentials in config
    at ClientRequest.<anonymous> (/Users/flocve/Sites/labs/notes-app-api/node_modules/aws-sdk/lib/http/node.js:83:34)
    at ClientRequest.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at ClientRequest.emit (events.js:185:7)
    at Socket.emitTimeout (_http_client.js:620:10)
    at Socket.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:185:7)
    at Socket._onTimeout (net.js:339:8)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
  message: 'Missing credentials in config',
  code: 'CredentialsError',
  time: 2017-04-17T10:06:21.387Z,
  retryable: true,
  originalError: 
   { message: 'Could not load credentials from any providers',
     code: 'CredentialsError',
     time: 2017-04-17T10:06:21.387Z,
     retryable: true,
     originalError: 
      { message: 'Connection timed out after 1000ms',
        code: 'TimeoutError',
        time: 2017-04-17T10:06:21.386Z,
        retryable: true } } }

```

I Follow the tutorial (2 times 🙂 ), but impossible to understand what is my problem.  
I used the region **eu-west-2** instead of **us-east-1**.

Did I forget something ?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/8 "2018-05-09T19:44:32Z")

</div>

_From @fwang on Tue Apr 18 2017 17:35:39 GMT+0000 (UTC)_  
  
@flocve Could you double check if these two files exist ~/.aws/config and ~/.aws/credentials

~/.aws/config should look like

```auto
[default]
region = eu-west-2

```

~/.aws/credentials should look like

```auto
[default]
aws_access_key_id = AKIXXXXGMPQAP123XXXX
aws_secret_access_key = JOsGrXxxXl8o8bXxXxbOf1RoDw2guXXxxXXxx123

```

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/9 "2018-05-09T19:44:33Z")

</div>

_From @eliocapelati on Sat Apr 22 2017 23:11:35 GMT+0000 (UTC)_  
  
Hello,

Following these steps, I have been getting an error on LAMBDA\_PROXY function of api gateway.

the response on request also includes the:

```
statusCode: 200,
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Credentials': true,
    },
    body: ....
```

and if a error (500) occur, the status code is 200.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/10 "2018-05-09T19:44:33Z")

</div>

_From @jayair on Sat Apr 22 2017 23:17:38 GMT+0000 (UTC)_  
  
@eliocapelati can you show me the full response that you are seeing?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/11 "2018-05-09T19:44:33Z")

</div>

_From @eliocapelati on Sat Apr 22 2017 23:19:51 GMT+0000 (UTC)_  
  
Here a 404 error… I just changed the 500 to 404…

 ![screen shot 2017-04-22 at 19 33 36](https://yyz2.discourse-cdn.com/flex032/uploads/serverless_stack/original/1X/5355460689d72405e6387e95b7827973703558c2.png)

**Update 1**  
Here the code of response-lib…

![screen shot 2017-04-22 at 20 25 04](https://yyz2.discourse-cdn.com/flex032/uploads/serverless_stack/original/1X/e3ca1f56359e2dbdffd34f48034c3b07eb4c3ffe.png)

**Update 2**  
And here my function (Ok, this is the get… but the same symptom at all):  
 ![screen shot 2017-04-22 at 20 28 31](https://yyz2.discourse-cdn.com/flex032/uploads/serverless_stack/original/1X/d70329cda234e747b4380c603ac988aa3fa4d574.png)

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/12 "2018-05-09T19:44:34Z")

</div>

_From @jayair on Mon Apr 24 2017 20:15:31 GMT+0000 (UTC)_  
  
@eliocapelati I’m a bit confused here. According to your code you are throwing the 404 error. That is how it should work right? There is no problem then right?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/13 "2018-05-09T19:44:34Z")

</div>

_From @deivers on Wed May 10 2017 12:52:18 GMT+0000 (UTC)_  
  
I’m getting:

```bash
{ ResourceNotFoundException: Requested resource not found
    at Request.extractError (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/protocol/json.js:48:27)
    at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:673:14)
    at Request.transition (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:675:12)
    at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at callNextListener (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
    at IncomingMessage.onEnd (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/event_listeners.js:254:11)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
  message: 'Requested resource not found',
  code: 'ResourceNotFoundException',
  time: 2017-05-10T12:45:43.839Z,
  requestId: '9AD2PP6137PVQV7O652HGL5JE3VV4KQNSO5AEMVJF66Q9ASUAAJG',
  statusCode: 400,
  retryable: false,
  retryDelay: 15.609907065688 }

```

It’s not clear to me which resource isn’t found.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/14 "2018-05-09T19:44:35Z")

</div>

_From @vfonsecapv on Thu May 11 2017 12:41:54 GMT+0000 (UTC)_  
  
Same problem here @deivers

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/15 "2018-05-09T19:44:35Z")

</div>

_From @jayair on Thu May 11 2017 17:46:29 GMT+0000 (UTC)_  
  
@deivers @vfonsecapv when are you seeing this error?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/16 "2018-05-09T19:44:35Z")

</div>

_From @ryanjcruz on Sat May 13 2017 01:11:00 GMT+0000 (UTC)_  
  
`$ serverless webpack invoke --function create --path event.json  
Serverless: Bundling with Webpack…  
Time: 679ms  
Asset Size Chunks Chunk Names  
create.js 4.17 kB 0 [emitted] create  
handler.js 2.28 kB 1 [emitted] handler  
Serverless: Run function create…

Type Error ---------------------------------------------

```
 Cannot read property 'handler' of undefined

```

`

I’m getting the error above when trying to run the test, not sure where to proceed from here.

Update: OK, my bad, turns out ‘functions’ isn’t aligned correctly and was tabbed, making it a property of provider. Untabbed it and works perfectly!

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/17 "2018-05-09T19:44:35Z")

</div>

_From @jayair on Sat May 13 2017 23:16:19 GMT+0000 (UTC)_  
  
@ryanjcruz Glad you figured it out. Just noticed somebody else is having a similar issue as well.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/18 "2018-05-09T19:44:36Z")

</div>

_From @manoaj on Sun May 21 2017 06:23:10 GMT+0000 (UTC)_  
  
```bash  
serverless webpack invoke --function create --path event.json  
Serverless: Bundling with Webpack…  
Time: 1287ms  
Asset Size Chunks Chunk Names  
create.js 6.35 kB 0 [emitted] create  
handler.js 2.28 kB 1 [emitted] handler  
Serverless: Run function create…  
{ statusCode: 500,  
headers:  
{ ‘Access-Control-Allow-Origin’: ‘\*’,  
‘Access-Control-Allow-Credentials’: true },  
body: ‘{“status”:false}’ }

```auto

When I invoke the create function I got the above error, I did everything as mentioned in the tutorial, I couldn't able to trace the error, kindly help me to resolve the issue.
If I change the callback function to ES6 promise then I got the 500 error response before that I got 200 response...

UPDATE: I wrongly passed the arguments name in the dynamodb-lib.js, it works fine now.
```

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/19 "2018-05-09T19:44:36Z")

</div>

_From @go4cas on Sun May 21 2017 08:49:39 GMT+0000 (UTC)_  
  
When running `serverless webpack invoke --function create --path event.json`, I get the following:

`Unexpected token import`

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/20 "2018-05-09T19:44:36Z")

</div>

_From @go4cas on Sun May 21 2017 09:05:02 GMT+0000 (UTC)_  
  
Okay, I fixed this with:

`npm install --save-dev babel-preset-es2015`

And then, changed `.babelrc` file:

```auto
{
  "plugins": ["transform-runtime"],
  "presets": ["react-app","es2015"]
}

```

[Next page](https://discourse.sst.dev/t/add-a-create-note-api/125.md?page=2)
