# How do I correctly specify the "path:" when setting up an http event for a Lambda function?

**URL:** <https://forum.serverless.com/t/how-do-i-correctly-specify-the-path-when-setting-up-an-http-event-for-a-lambda-function/1416>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [March 1, 2017, 4:54pm UTC](https://forum.serverless.com/t/how-do-i-correctly-specify-the-path-when-setting-up-an-http-event-for-a-lambda-function/1416 "2017-03-01T16:54:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![n44o](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@n44o](https://forum.serverless.com/u/n44o)\
**Post date:** [March 1, 2017, 4:54pm UTC](https://forum.serverless.com/t/how-do-i-correctly-specify-the-path-when-setting-up-an-http-event-for-a-lambda-function/1416/1 "2017-03-01T16:54:44Z")

</div>

After much trial and error, I’m going to ask for help on a (seemingly) simple issue.  
I’m trying to set up API gateway to handle http requests. My serverless.yml file looks like this:

```
functions:
  create:
    handler: handlers/createUser.Create
    events:
      - http:
          path: createUser/Create
          method: post
          integration: lambda-proxy
          cors: true

```

I have a “handlers/” directory at the root of my serverless service, containing the handler “createUser.js”.  
Inside of “createUser.js”, I’m exporting like this:  
export default function Create(event, context, callback) {  
…  
}  
After a successful deployment, I’m trying to use the endpoint which is:  
[https://XXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/createUser/Create](https://XXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/createUser/Create)  
(using the proper url of course, not XXXXXXXX !) , but I keep receiving the same error:  
{“message”:“Missing Authentication Token”}

According to this article  
[http://www.awslessons.com/2017/aws-api-gateway-missing-authentication-token/](http://www.awslessons.com/2017/aws-api-gateway-missing-authentication-token/)  
There are 3 possible causes of this error, and I’ve eliminated 2 of them, leaving “Incorrect URL String” as the culprit. I feel like I’m probably causing this error by the way I’m specifying my http path and/or handler… any help would be much appreciated!

Note: I’ve also tried this in my sls.yml:  
path: createUser/Create  
and using this url: [https://XXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/handlers/createUser/Create](https://XXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/handlers/createUser/Create)  
but the result is the same error.

---

<div class="post-metadata">

**Author:** ![jjasonclark](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jjasonclark/32/303_2.png) [@jjasonclark](https://forum.serverless.com/u/jjasonclark)\
**Post date:** [March 1, 2017, 6:28pm UTC](https://forum.serverless.com/t/how-do-i-correctly-specify-the-path-when-setting-up-an-http-event-for-a-lambda-function/1416/2 "2017-03-01T18:28:00Z")

</div>

Your formatting is wrong in the `serverless.yml` file. You need to nest another level deep under http.

```auto
functions:
  create:
    handler: handlers/createUser.Create
    events:
      - http:
          path: createUser/Create
          method: post
          cors: true

```

Also I think you need to not default export your create function.

```auto
export function Create(event, context, callback) {
...
}

```

Hope this helps 😅

---

<div class="post-metadata">

**Author:** ![n44o](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@n44o](https://forum.serverless.com/u/n44o)\
**Post date:** [March 1, 2017, 6:46pm UTC](https://forum.serverless.com/t/how-do-i-correctly-specify-the-path-when-setting-up-an-http-event-for-a-lambda-function/1416/3 "2017-03-01T18:46:48Z")

</div>

Thank you. I’ll try changing the way I’m exporting my function. My formatting is actually correct in my serverless.yml, but I messed it up while pasting, sorry about that.

Update:  
I’ve removed the handlers/ directory from the picture to simplify. My handler function createUser.js is now in the root of my service with my serverless.yml.

I’m exporting my function like this:  
export function Create(event, context, callback) {  
//code  
}

Serverless.yml like this:

```
functions:
  create:
     handler: createUser.Create
     events:
        - http:
             path: createUser/Create
             method: post
             integration: lambda-proxy
             cors: true

When I test the function "create" in the AWS console, I'm getting this:
 {
  "errorMessage": "Cannot find module '/var/task/createUser'",
  "errorType": "Error",
  "stackTrace": [
    "require (internal/module.js:12:17)"
  ]
}

```

I should note that I’m using the serverless-babel-plugin as well, but I’m not sure if that’s relevant here or not… It’s possible that the issue is in the packaging of my service

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [March 1, 2017, 10:09pm UTC](https://forum.serverless.com/t/how-do-i-correctly-specify-the-path-when-setting-up-an-http-event-for-a-lambda-function/1416/4 "2017-03-01T22:09:55Z")

</div>

It looks like the file is missing. Run `sls deploy -n`. This should create a zip file inside your `.serverless` folder. Unzip that file and you can see what’s being uploaded. It may be that serverless-babel-plugin is putting the compiled JS files into another folder (I don’t use it so I’m not sure how it works).

---

<div class="post-metadata">

**Author:** ![n44o](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@n44o](https://forum.serverless.com/u/n44o)\
**Post date:** [March 1, 2017, 10:11pm UTC](https://forum.serverless.com/t/how-do-i-correctly-specify-the-path-when-setting-up-an-http-event-for-a-lambda-function/1416/5 "2017-03-01T22:11:42Z")

</div>

Thanks for the tip, will try that now.

---

<div class="post-metadata">

**Author:** ![n44o](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@n44o](https://forum.serverless.com/u/n44o)\
**Post date:** [March 6, 2017, 5:24pm UTC](https://forum.serverless.com/t/how-do-i-correctly-specify-the-path-when-setting-up-an-http-event-for-a-lambda-function/1416/6 "2017-03-06T17:24:01Z")

</div>

I managed to get it working. I don’t think the serverless-babel-plugin was an issue, as all the required files seemed to be zipped correctly. ( However, I decided to remove the plugin for other reasons)  
In the end, this is what I’m using successfully:

serverless.yml:

```
functions:
  create:
    handler: handlers/subscribeUser.subscribe
    events:
      - http:
          path: subscribe
          method: post
          integration: lambda-proxy
          cors: true

```

and in my handler (subscribeUser.js):

```
exports.subscribe = subscribe;
function subscribe(event, context, callback) {
    // code
}

```

All is working well now!
