“781306366706886” is the custom field Id and the “781306366706887” enum Id.
I have been going around for days, search and tried multiple solutions to similar problems in this community and stack overflow, but none of them have worked.
Hmmm, your syntax looks right to me. Are you 100.0% sure those id values are correct, especially the enum id? That’s the id of the specific enum value you’re wanting to set, right?
I just ran one of my unit tests that sets custom fields for a task, and grabbed the JSON I send to the Asana service:
{
"name": "Testing",
"assignee": "159356326117471",
"custom_fields": {
"743926788382115": "3.14",
"744020393575926": "This is some text.",
"743926788382110": "754688651720395"
}
}
743926788382115 is the custom field ID for a number type custom field.
744020393575926 is the custom field ID for a text type custom field.
743926788382110 is the custom field ID for an enum type custom field, and 754688651720395 is the ID for one of the enum values that’s been defined for that field.
Thank you rob.
With the Data above, I get the following response:
Server Error: Oops! An unexpected error occurred while processing this request. The input may have contained something the server did not know how to handle. For more help, please contact api-support@asana.com and include the error phrase from this response.
@Joe_Trollo, @Matt_Bramlage, any ideas? Does her error message text tell you anything about why she can’t add a custom field to a task? Her syntax looks correct to me.
Based on that message, I suspect that the custom field 781306366706886 is not on the project 781671016689811. In Asana, you can only set a custom field on a task if that task is in a project that has that custom field (or is about to be created in a project that has that custom field).
I can verify that there are no custom fields set on that project.
If you’re looking to do this in the API, you can POST a request to /projects/:project_id/addCustomFieldSetting, which will associate the custom field with the project. Then it should be possible to set the value of the custom field on the task as above.
You can use those custom fields. But you have to assign them to the new project before trying to attach them to tasks in that project. You can do this via the API using the method Matt_Bramlage showed above; or you can do it via the UI using the Manage Custom Fields option on the project menu.
And then I have a test function which feeds that function with example IDs that really exist. However, the console throws the error:
TypeError: Cannot read property ‘id’ of undefined
The function works fine when I delete the line with “custom_fields”. So the error must appear exactly here. I don’t know if it is relevant, but my editor does not color “fieldId” (which he usually only does with unknown variables) in that line.
I have been troubleshooting for hours. Actually, my initial goal was to use “insert_after” and/or put the task in a given section (I have read the documentation and posts about this here in the forum), but this also produced errors, so I thought the easiest workaround is a custom field.
Hello everyone,
I’m sorry to re-open the case here, but I have some struggles with posting a task with a custom field.
When I get on this url: https://app.asana.com/api/1.0/custom_fields/1181175364270501/
I get this Json:
{
“data”: {
“gid”: “1181175364270501”,
“name”: “Hash”,
“resource_subtype”: “text”,
“resource_type”: “custom_field”,
“type”: “text”,
“is_global_to_workspace”: true
}
}
So my field named “hash” is detected and has the id “1181175364270501”.
But when I try to create a task with this body:
{
“data”: {
“custom_fields”:{
“1181175364270501”: “test”
},
“html_notes”: “Mittens really likes the stuff from Humboldt.”,
“name”: “Buy catnip”,
“project”: “1181175364270497”,
“resource_subtype”: “default_task”,
“workspace”: “17325551900806”
}
}
I get this error:
“message”: “Custom field with ID 1181175364270501 is not on given object”
My custom field is a text field and I can see the field in my project (both with a get to the api and in the interface)
You’re sure that it’s the exact same custom field gid and not another field that has the same name? Because that error means Asana doesn’t find that custom field gid attached to that project…