Updating Custom Field Enums


#1

I’ve created a custom field enum via the api without a problem.

I’m now trying to update it but i keep getting the enum_option_duplicate_name error.
I’m doing a PUT request not a POST and passing the params: name, color & enabled.

Any ideas on what i’m doing wrong or what i should be doing?

Cheers


#2

Hi @Samuel_Birch, can you please share the names of the existing enum options in your custom field, indicate which one you are trying to change, and what name you’re trying to change it to?


#3

Hi, I’m just playing around at the moment trying to get it to update.
I can add enums no problem, its has issues when trying to update. If i change the name then it works fine, but if i try to change the color or update the enabled status without changing the name, thats when i get the error. If i omit the name (docs says its required) then it errors too.


#4

We are unable to reproduce this issue, and will need you to provide more information about your request and custom field. Can you please post an example of the request you’re making, either as a cURL command or an equivalent code snippet? Please also post the names of the enum options in your custom field and indicate which one you are trying to change.


#5

Here is the response & request: (i’m using the Asana PHP framework)
All i’m trying to do in this request is change the color from red to aqua.

Httpful\Response#1
(
[body] => stdClass#2
(
[errors] => [
0 => stdClass#3
(
[error] => ‘enum_option_duplicate_name’
[message] => ‘An enum option already exists with the name: Test Option 1.’
[user_message] => ‘An enum option already exists with the name: Test Option 1.’
[help] => 'For more information on API status codes and how to handle them, read the docs on errors: ’
)
]
)
[raw_body] => ‘{“errors”:[{“error”:“enum_option_duplicate_name”,“message”:“An enum option already exists with the name: Test Option 1.”,“user_message”:“An enum option already exists with the name: Test Option 1.”,“help”:"For more information on API status codes and how to handle them, read the docs on errors: "}]}’
[headers] => Httpful\Response\Headers#4
(
[Httpful\Response\Headers:headers] => [
‘server’ => ‘nginx’
‘date’ => ‘Thu, 27 Sep 2018 10:10:29 GMT’
‘content-type’ => ‘application/json; charset=UTF-8’
‘content-length’ => ‘365’
‘connection’ => ‘keep-alive’
‘cache-control’ => ‘no-store’
‘pragma’ => ‘no-cache’
‘set-cookie’ => ‘TooBusyRedirectCount=0’
‘content-security-policy-report-only’ => ‘report-uri /app.asana.com/-/csp_report;default-src ‘none’;frame-src ‘none’;frame-ancestors ‘none’’
‘asana-change’ => ‘name=new_rich_text;info=/asa.na/api-rich-text’
‘x-asana-api-version’ => ‘1.0’
‘x-robots-tag’ => ‘none’
]
)
[raw_headers] => ‘HTTP/1.1 403 Forbidden
Server: nginx
Date: Thu, 27 Sep 2018 10:10:29 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 365
Connection: keep-alive
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: TooBusyRedirectCount=0
Content-Security-Policy-Report-Only: report-uri /app.asana.com/-/csp_report;default-src ‘none’;frame-src ‘none’;frame-ancestors ‘none’
Asana-Change: name=security_headers;info=/asa.na/api-sh;affected=true
Asana-Change: name=new_rich_text;info=/asa.na/api-rich-text
X-Asana-Api-Version: 1.0
X-Robots-Tag: none’
[request] => Httpful\Request#5
(
[uri] => ‘/app.asana.com/api/1.0/enum_options/840607060035458’
[method] => ‘PUT’
[headers] => [
‘content-type’ => ‘application/json’
‘X-Asana-Client-Lib’ => ‘version=0.8.0&language=PHP&language_version=7.1.22&os=Darwin&os_version=16.7.0’
‘Authorization’ => 'Bearer xxxxxxxx’
‘Content-Length’ => 63
]
[raw_headers] => 'PUT /api/1.0/enum_options/840607060035458 HTTP/1.1
Host: app.asana.com
Expect:
User-Agent: Httpful/0.2.20 (cURL/7.54.0 PHP/7.1.22 (Darwin) nginx/1.15.3 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36)
Content-Type: application/json
Accept: /; q=0.5, text/plain; q=0.8, text/html;level=3;q=0.9, application/json
content-type: application/json
X-Asana-Client-Lib: version=0.8.0&language=PHP&language_version=7.1.22&os=Darwin&os_version=16.7.0
Authorization: Bearer xxxxxxxx
Content-Length: 63

[strict_ssl] => false
[content_type] => ‘application/json’
[expected_type] => ‘application/json’
[additional_curl_opts] => []
[auto_parse] => true
[serialize_payload_method] => 2
[username] => null
[password] => null
[serialized_payload] => ‘{“data”:{“name”:“Test Option 1”,“color”:“aqua”,“enabled”:true}}’
[payload] => ‘{“data”:{“name”:“Test Option 1”,“color”:“aqua”,“enabled”:true}}’
[parse_callback] => null
[error_callback] => null
[send_callback] => null
[follow_redirects] => false
[max_redirects] => 25
[payload_serializers] => []
[_ch] => {unknown}
[_debug] => null
)
[code] => 403
[content_type] => ‘application/json’
[parent_type] => ‘application/json’
[charset] => ‘UTF-8’
[meta_data] => [
‘url’ => ‘/app.asana.com/api/1.0/enum_options/840607060035458’
‘content_type’ => ‘application/json; charset=UTF-8’
‘http_code’ => 403
‘header_size’ => 584
‘request_size’ => 659
‘filetime’ => -1
‘ssl_verify_result’ => 0
‘redirect_count’ => 0
‘total_time’ => 0.971265
‘namelookup_time’ => 0.051046
‘connect_time’ => 0.144223
‘pretransfer_time’ => 0.342482
‘size_upload’ => 63
‘size_download’ => 365
‘speed_download’ => 375
‘speed_upload’ => 64
‘download_content_length’ => 365
‘upload_content_length’ => 63
‘starttransfer_time’ => 0.971226
‘redirect_time’ => 0
‘redirect_url’ => ‘’
‘primary_ip’ => ‘52.6.28.224’
‘certinfo’ => []
‘primary_port’ => 443
‘local_ip’ => ‘192.168.0.32’
‘local_port’ => 52663
]
[is_mime_vendor_specific] => false
[is_mime_personal] => false
[Httpful\Response:parsers] => null
)


#6

Thanks for that information, I was able to find and reproduce the issue. In the request you shared, you’re attempting to update the name of the enum option without giving it a new, distinct name. This shouldn’t be an issue, and a fix will go out for this soon, but in the meantime you can work around this error by not setting the name if you don’t wish to actually change it.


#7

Thanks Joe, I did try not including the name but i got an error message saying that the name was required.