# Having difficulty with Asana API and updating custom field values in Node

**URL:** <https://forum.asana.com/t/having-difficulty-with-asana-api-and-updating-custom-field-values-in-node/573607>\
**Category:** API & Developers\
**Tags:** custom-fields\
**Created:** [17 October 2023 15:00 UTC](https://forum.asana.com/t/having-difficulty-with-asana-api-and-updating-custom-field-values-in-node/573607 "2023-10-17T15:00:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Fouse](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/alexander_fouse/32/91326_2.png) [@Alexander\_Fouse](https://forum.asana.com/u/Alexander_Fouse)\
**Post date:** [17 October 2023 15:00 UTC](https://forum.asana.com/t/having-difficulty-with-asana-api-and-updating-custom-field-values-in-node/573607/1 "2023-10-17T15:00:49Z")

</div>

I’m sure I’m probably just missing something simple, but for the life of me I can’t update a custom field on a task. Here are the various snippets I’ve tried:

> client.tasks.updateTask( my\_task\_id, { my\_custom\_field\_id: update\_value })

> client.tasks.updateTask( my\_task\_id, {“custom\_fields”: {my\_custom\_field\_id: update\_value} })  
> //this one returns an Invalid Request error

> client. tasks.updateTask( my\_task\_id, {“data”: {“custom\_fields”: { my\_custom\_field\_id: update\_value} } })

For each of the above, I’ve tried with and without quotes around: data, custom\_fields, and my\_custom\_field\_id

Note: I’m using the actual numbers, not variable names, until I get it working.  
Note: I was initially attempting to update a custom date field, but I also can’t even update a custom text field.  
Note: I’ve been getting custom field data from tasks for years now without issue. This is the first I’m trying to update custom fields.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Alexander\_Fouse](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/alexander_fouse/32/91326_2.png) [@Alexander\_Fouse](https://forum.asana.com/u/Alexander_Fouse)\
**Post date:** [17 October 2023 16:10 UTC](https://forum.asana.com/t/having-difficulty-with-asana-api-and-updating-custom-field-values-in-node/573607/2 "2023-10-17T16:10:06Z")

</div>

Oddly, I can update the field through the API documentation Try It for Node – but the code shown doesn’t change with the inputs in the documentation.

It’s always:

> client.tasks.updateTask(taskGid, {field: “value”, field: “value”, pretty: true})

I assume the button performs the operation in a standard way, and not the language selected (which makes sense). But looking at the header details, I don’t see how my code isn’t doing the same thing.

---

<div class="post-metadata">

**Author:** ![John\_Vu](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/john_vu/32/97235_2.png) [@John\_Vu](https://forum.asana.com/u/John_Vu)\
**Post date:** [17 October 2023 17:21 UTC](https://forum.asana.com/t/having-difficulty-with-asana-api-and-updating-custom-field-values-in-node/573607/3 "2023-10-17T17:21:44Z")

</div>

Hi @Alexander_Fouse,

From my understand it looks like you are trying to update a custom field value on a task through our [Update a task](https://developers.asana.com/reference/updatetask) endpoint. Here’s how you would do this with our [node-asana v1.0.2](https://github.com/Asana/node-asana/tree/v1.0.2) client library:

```javascript
const asana = require('asana');

const client = asana.Client.create().useAccessToken("<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>");
const taskGid = "<YOUR_TASK_GID>"

client.tasks.updateTask(taskGid, {custom_fields: {"<YOUR_CUSTOM_FIELD_GID>": "<CUSTOM_FIELD_VALUE>"}})
    .then((result) => {
        console.log(result);
    });

```

I think the difference here is no need for the quotes for “custom\_fields” key. Your last request also has a space in between the client and tasks → `client. tasks` → should be `client.tasks`

* * *

> Oddly, I can update the field through the API documentation Try It for Node – but the code shown doesn’t change with the inputs in the documentation.

Our documentation site does not support trying our client libraries through it so when you make changes to the field inputs/text inputs in our docs it will not change in the sample code editor to the right. This will only work for shell and other samples like Axios, Node-fetch etc…

 ![Screenshot 2023-10-17 at 10.17.00 AM](https://us1.discourse-cdn.com/asana/original/3X/2/9/2960568680f4340822178d50f73e9abe87212227.png)

---

<div class="post-metadata">

**Author:** ![Alexander\_Fouse](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/alexander_fouse/32/91326_2.png) [@Alexander\_Fouse](https://forum.asana.com/u/Alexander_Fouse)\
**Post date:** [17 October 2023 17:27 UTC](https://forum.asana.com/t/having-difficulty-with-asana-api-and-updating-custom-field-values-in-node/573607/4 "2023-10-17T17:27:00Z")

</div>

Thank you!!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [24 October 2023 17:27 UTC](https://forum.asana.com/t/having-difficulty-with-asana-api-and-updating-custom-field-values-in-node/573607/5 "2023-10-24T17:27:09Z")

</div>

Closed on 24 October 2023 17:27 UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
