[BREAKING] Update ticket field dropdown fields by 'value' instead of 'id' Follow

Comments

8 comments

  • Avatar
    James Q

    Im using curl in windows, and just realised the code here is different from the code on your API page, so ive now tried the code here but im still getting 422 error.

    Have you got any idea whats wrong with it?

    curl https://companyname.zendesk.com/api/v2/ticket_fields/27950071.json ^
    -H "Content-Type: application/json" -X PUT ^
    -d '{"ticket_field": {"custom_field_options": [{"name": "Choice 2", "value": "choice_2"}, {"name": "Choice 1", "value": "choice_1"}, {"name": "Choice 3", "value": "choice_3"**}]}}' ^
    -v -u username@domain.com:password

  • Avatar
    Joseph May

    Hi James-

    There are some caveats to using cURL in Windows. Please take a look here to learn some more: https://support.zendesk.com/hc/en-us/articles/203691436-Installing-and-using-cURL#curl_win.

    Storing your JSON in a data file (recommended) or escaping all necessary chars are your options.

  • Avatar
    James Q

    Hi Jospeh,

    Im still getting 422 error,

    so now i have the following which i paste in cmd

    curl https://comapnyname.zendesk.com/api/v2/ticket_fields/27950071.json ^
    -d @json.txt ^
    -H "Content-Type: application/json" -X PUT ^
    -v -u user@user.com:password

    and my file; json.txt, contains:
    {"ticket_field": {"custom_field_options": [{"name": "Choice 2", "value": "choice_2"}, {"name": "Choice 1", "value": "choice_1"}, {"name": "Choice 3", "value": "choice_3"**}]}}

    from what i can see im doing everything that page says to now.

  • Avatar
    James Q

    Have i got the end part of the url correct, 27950071.json
    27950071 being the id number for custom field id?

  • Avatar
    Joseph May

    Hi James-

    Could you try the following, being sure to replace subdomain, field ID, and auth values:

    curl https://{subdomain}.zendesk.com/api/v2/ticket_fields/{id}.json -H "Content-Type: application/json" -X PUT -d "{\"ticket_field\": {\"custom_field_options\": [{\"name\": \"Choice 2\", \"value\": \"choice_2\"}, \"name\": \"Choice 1\", \"value\": \"choice_1\"}, {\"name\": \"Choice 3\", \"value\": \"choice_3\"}]}}" -v -u {email_address}:{password}

  • Avatar
    Joseph May

    Also, and I am only just noticing this, but don't copy/paste unless you are running this through a linter - those smartquotes are also notorious. I would make sure that there aren't any contained in your call whatsoever.

  • Avatar
    James Q

    Hi Joseph, the issue was me copying and pasting, cant believe i missed that causing the issue, ive ended up going for the way with the json in separate file which is called in and works now, cheers for the help!!

  • Avatar
    Joseph May

    Good to hear it! I wouldn't know if I hadn't have done it myself in the past :)

Please sign in to leave a comment.

Powered by Zendesk