Updating a User Field with Zendesk Api
AnsweredHi, I want to use Zendesk Api to update a user field in the profile. In order words, I would like to pass from a blank or "-" value to a new value that i want to specify within the Put request. I do not know if Zendesk provides a command for doing so. Currently, I have found the doc for managing user fields with the API and I see comands for (Update User Field, create or update user field option, etc), but I am not sure which one should I use to update a blank space in that user field and set it to a new value.
https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#update-user-field
Note: The user field type is drop-down
-
Hi Juan Julio Montreuil Berrocal
I think what you are looking for is updating the values of user fields that you already created. So you will need to do so from the user end point `/api/v2/users/{user_id}`
Example:
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}.json \
-d '{"user":
{"user_fields": {
"user_field_key_1": "option"
}
}}' \
-H "Content-Type: application/json" -X PUT \
-v -u {user}:{api_key}
To set it to null (-), simply replace the "option" value with "".
I hope I managed to help.
-
Hi Ahmed! thanks for your help. So in order to specify the user field to be changed, I replace "user_field_key_1" with the user field ID or I should put it in another part of that code block?
-
Hi Juan Julio Montreuil Berrocal
You would actually need the field unique 'key', rather than its id. It should replace 'user_field_key_1' as you expected.
-
Thanks for jumping in to problem solve, Ahmed Zaid!
Please sign in to leave a comment.
4 Comments