# Set task custom field using curl

**URL:** <https://forum.asana.com/t/set-task-custom-field-using-curl/51404>\
**Category:** API & Developers\
**Created:** [3 June 2019 09:42 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404 "2019-06-03T09:42:23Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Floris\_Thijssen](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/floris_thijssen/32/35228_2.png) [@Floris\_Thijssen](https://forum.asana.com/u/Floris_Thijssen)\
**Post date:** [3 June 2019 09:42 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/1 "2019-06-03T09:42:23Z")

</div>

I’m trying to create a script that can create tasks for me and set their custom fields.  
So far I figured out that my project ID is 727740646475748.  
If I call GET /projects/727740646475748, I find that my custom field ID 727729591481443 is and value ID is 727729591481447. Full json @ [{ "data": { "id": 727740646475748, "gid": "727740646475748", " - Pastebin.com](https://pastebin.com/XqDLst8G), I’m trying to select the “Cassandra Test” enum value.

According to this page: /developers/documentation/getting-started/custom-fields  
This should work  
curl --request PUT -H “Authorization: Bearer \<personal\_access\_token\>”   
/api/1.0/tasks/1125479699210021   
-d   
‘{  
“data”: {  
“custom\_fields”:{  
“727729591481443”:“727729591481447”  
}  
}  
}’  
But I get  
{“errors”:[{“message”:“Could not interpret {\n "data": {\n "custom\_fields":{\n "727729591481443":"727729591481447"\n }\n }\n} as an identifier in {\n "data": {\n "custom\_fields":{\n "727729591481443":"727729591481447"\n }\n }\n}.”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: /developers/documentation/getting-started/errors”}]}

According to this page /developers/api-reference/tasks#setting\_custom\_field\_values  
This should work  
curl --request PUT -H “Authorization: Bearer \<personal\_access\_token\>”   
[https://app.asana.com/api/1.0/tasks/1125479699210021](https://app.asana.com/api/1.0/tasks/1125479699210021)   
-d “custom\_fields:{727729591481443:727729591481447}”  
But I get  
{“errors”:[{“message”:“Could not interpret custom\_fields:{727729591481443:727729591481447} as an identifier in custom\_fields:{727729591481443:727729591481447}.”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: /developers/documentation/getting-started/errors”}]}

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Bastien\_Siebman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/bastien_siebman/32/172354_2.png) [@Bastien\_Siebman](https://forum.asana.com/u/Bastien_Siebman)\
**Post date:** [3 June 2019 11:17 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/2 "2019-06-03T11:17:50Z")

</div>

(can you use the editor to format your code please? thanks 👍)

---

<div class="post-metadata">

**Author:** ![Floris\_Thijssen](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/floris_thijssen/32/35228_2.png) [@Floris\_Thijssen](https://forum.asana.com/u/Floris_Thijssen)\
**Post date:** [3 June 2019 12:50 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/3 "2019-06-03T12:50:52Z")

</div>

I didn’t see a format code option, so I just left it. I also can’t seem to find an edit button, can I even edit posts? I’m new here.

---

<div class="post-metadata">

**Author:** ![Bastien\_Siebman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/bastien_siebman/32/172354_2.png) [@Bastien\_Siebman](https://forum.asana.com/u/Bastien_Siebman)\
**Post date:** [3 June 2019 14:07 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/4 "2019-06-03T14:07:45Z")

</div>

Indeed you can’t when you are new member 🙂

---

<div class="post-metadata">

**Author:** ![Bastien\_Siebman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/bastien_siebman/32/172354_2.png) [@Bastien\_Siebman](https://forum.asana.com/u/Bastien_Siebman)\
**Post date:** [3 June 2019 14:24 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/5 "2019-06-03T14:24:13Z")

</div>

Documentation says:  
`SETTING CUSTOM FIELD VALUES Custom fields are set with PUT requests similarly to setting other fields on tasks; the format of the request is to set the id to the new value. That is, custom_fields:{custom_field_id:custom_field_value}`  
but looks like you are setting `custom_fields` on your end…

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [3 June 2019 16:06 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/6 "2019-06-03T16:06:15Z")

</div>

@Floris_Thijssen Try following the syntax shown in this post:

> [@Api & Custom Fields](https://forum.asana.com/t/api-custom-fields/1733/18):
>
> Hey all, catching back up on backlog here. @Phil_Seeman It’s not well documented (I’ll create a follow up task to fix this) but indexing into arrays using form data is done with square brackets both for offset-based arrays (like collaborators[0], collaborators[1]) and for associative arrays (using IDs). Try: curl --request PUT -H "authorization: Bearer MY-PERSONAL-ACCESS-TOKEN" https://app.asana.com/api/1.0/tasks/718125926216046 --data-urlencode "custom\_fields[744020393575926]=A field updated …

---

<div class="post-metadata">

**Author:** ![Floris\_Thijssen](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/floris_thijssen/32/35228_2.png) [@Floris\_Thijssen](https://forum.asana.com/u/Floris_Thijssen)\
**Post date:** [4 June 2019 09:08 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/7 "2019-06-04T09:08:29Z")

</div>

I tried  
`curl --request PUT -H "authorization: Bearer SNIP" https://app.asana.com/api/1.0/tasks/1125479699210021 --data-urlencode "custom_fields[727740646475736]=1109215504501105"`  
And it gave me  
`{"errors":[{"message":"custom_fields: Value cannot be an array: []","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]}`

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [4 June 2019 13:51 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/8 "2019-06-04T13:51:21Z")

</div>

Ah wait, I think there’s a typo in what was suggested - I think it should be `custom_field` singular. In other words, try:

`curl --request PUT -H "authorization: Bearer SNIP" https://app.asana.com/api/1.0/tasks/1125479699210021 --data-urlencode "custom_field[727740646475736]=1109215504501105"`

---

<div class="post-metadata">

**Author:** ![Floris\_Thijssen](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/floris_thijssen/32/35228_2.png) [@Floris\_Thijssen](https://forum.asana.com/u/Floris_Thijssen)\
**Post date:** [5 June 2019 11:45 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/9 "2019-06-05T11:45:37Z")

</div>

`curl --request PUT -H "authorization: Bearer SNIP" https://app.asana.com/api/1.0/tasks/1125479699210021 --data-urlencode "custom_fields[727740646475736]=1109215504501105"`  
Returns the JSON of the task, but the task itself isn’t getting changed. Output: [{ "data": { "assignee": { "gid": "695462050098932", "id": - Pastebin.com](https://pastebin.com/VTFAg1cM)  
I also noticed that the JSON that gets returned has different IDs than the one I use, so I tried using `--data-urlencode "custom_field[727729591481443]=727729591481449"`  
But I’m still just getting the JSON back and the task isn’t getting changed

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [5 June 2019 13:37 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/10 "2019-06-05T13:37:54Z")

</div>

Arghh, just tried it myself and I get the same result - it returns the task as if it worked but the custom field value is _ **not** _ changed.

@Joe_Trollo @Jeff_Schneider @Matt_Bramlage @Ross_Grambo Any ideas here, guys, on what the proper syntax is to update a task’s custom field value via curl?

---

<div class="post-metadata">

**Author:** ![Ross\_Grambo](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/ross_grambo/32/68568_2.png) [@Ross\_Grambo](https://forum.asana.com/u/Ross_Grambo)\
**Post date:** [5 June 2019 17:46 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/11 "2019-06-05T17:46:36Z")

</div>

It works for me if I use:

`curl -X PUT https://app.asana.com/api/1.0/tasks/<task-id> -H 'Authorization: Bearer <pat>' -H "Content-Type: application/json" -d '{"data":{"custom_fields":{"<custom-field-id>":"It worked!"}}}'`

Does this work for you?

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [5 June 2019 19:23 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/12 "2019-06-05T19:23:37Z")

</div>

Not me - when I try that, I get:  
`"Could not parse request data, invalid JSON"`

@Floris_Thijssen, how about you? Does it work for you?

---

<div class="post-metadata">

**Author:** ![Floris\_Thijssen](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/floris_thijssen/32/35228_2.png) [@Floris\_Thijssen](https://forum.asana.com/u/Floris_Thijssen)\
**Post date:** [6 June 2019 08:11 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/13 "2019-06-06T08:11:20Z")

</div>

I got a JSON error as well, but that’s because the first double qoute in `“<custom-field-id>"` isn’t a double quote. If I correct that, it just returns the JSON of the task again, but no fields are getting updated. Maybe it has something to do with the fact that my custom field is an enum instead of a string?  
Also, this is starting to look more like a bug, can someone move this thread to the report-a-bug category?

---

<div class="post-metadata">

**Author:** ![Floris\_Thijssen](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/floris_thijssen/32/35228_2.png) [@Floris\_Thijssen](https://forum.asana.com/u/Floris_Thijssen)\
**Post date:** [6 June 2019 08:12 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/14 "2019-06-06T08:12:20Z")

</div>

oh never mind, looks like I can move it myself

---

<div class="post-metadata">

**Author:** ![Natalia](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/natalia/32/34795_2.png) [@Natalia](https://forum.asana.com/u/Natalia)\
**Post date:** [11 June 2019 11:29 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/15 "2019-06-11T11:29:59Z")

</div>

Hi @Floris_Thijssen. Thank you for reaching out!

All the posts related to API Question including Bugs are handled in the #developersAPI category.

If it’s Ok with you, I’m moving this post back to #developersAPI so our team can directly assist you on this issue.

---

<div class="post-metadata">

**Author:** ![Joe\_Trollo](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/joe_trollo/32/4025_2.png) [@Joe\_Trollo](https://forum.asana.com/u/Joe_Trollo)\
**Post date:** [25 July 2019 20:45 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/16 "2019-07-25T20:45:00Z")

</div>

The issue here is a missing content type header. @Ross_Grambo was able to make a successful cURL request because he added `-H "Content-Type: application/json"` to the command. Without that, the API won’t correct interpret the body and you’ll see a `Cannot interpret...` error.

@Phil_Seeman, you likely got an invalid JSON error when running Ross’ command because he accidentally had a “smart” quote in the body of his request, which is invalid JSON. `“<custom-field-id>"` should be `"<custom-field-id>"` (note the difference in the first character).

---

<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:** [30 May 2025 19:07 UTC](https://forum.asana.com/t/set-task-custom-field-using-curl/51404/17 "2025-05-30T19:07:45Z")

</div>

Closed on 30 May 2025 19:07 UTC


