# Can't create task in coded action due to TypeError

**URL:** <https://community.hubspot.com/t/cant-create-task-in-coded-action-due-to-typeerror/72425>\
**Category:** APIs & Integrations\
**Created:** [January 8, 2023, 9:03pm UTC](https://community.hubspot.com/t/cant-create-task-in-coded-action-due-to-typeerror/72425 "2023-01-08T21:03:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsprunk](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tsprunk/32/90690_2.png) [@tsprunk](https://community.hubspot.com/u/tsprunk)\
**Post date:** [January 8, 2023, 9:03pm UTC](https://community.hubspot.com/t/cant-create-task-in-coded-action-due-to-typeerror/72425/1 "2023-01-08T21:03:03Z")

</div>

I’m looking to create tasks in a coded action and am running into TypeErrors even though everything seems to match the API documentation. Anyone know what I’m doing wrong?

NOTE: I’m aware that there’s already a workflow action to create tasks, I need to go beyond what’s possible with that action, but can’t even get it to create a simple task to begin with.

Current action code:

 ![Screen Shot 2023-01-08 at 3.02.11 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/9/79e9992d972054eb5c0c8dfe7a02510eefa93a43.png)

Error:

```auto
TypeError: Cannot read properties of undefined (reading 'basicApi')
 at Object.exports.main (/var/task/file.js:22:61)
 at Runtime.exports.hubspot_handler [as handler] (/var/task/hubspotHandler.js:6:21)
 at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1089:29)

```

My code’s based off the documentation here: [https://developers.hubspot.com/docs/api/crm/tasks](https://developers.hubspot.com/docs/api/crm/tasks)

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 9, 2023, 6:22pm UTC](https://community.hubspot.com/t/cant-create-task-in-coded-action-due-to-typeerror/72425/2 "2023-01-09T18:22:23Z")

</div>

Hi, @tsprunk 👋 Let’s see if we can get some community insight. Hey, @louischausse @LMeert, do you have any experience here?

Thank you very much! — Jaycee

---

<div class="post-metadata">

**Author:** ![tsprunk](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tsprunk/32/90690_2.png) [@tsprunk](https://community.hubspot.com/u/tsprunk)\
**Post date:** [January 11, 2023, 2:11am UTC](https://community.hubspot.com/t/cant-create-task-in-coded-action-due-to-typeerror/72425/3 "2023-01-11T02:11:06Z")

</div>

Hey [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) it looks like there may be an error in the documentation. It appears that rather than:

hubspotClient.crm.objects.tasks.basicApi.create(SimplePublicObjectInput);

It should be:

hubspotClient.crm.objects.basicApi.create(“tasks”,SimplePublicObjectInput);
