Hi All,
I am trying to add new entry to one of the custom field of Zendesk. For adding new entry, we need to send existing entries to the API endpoint.
When I get the existing entries, following is the output:
[
{
"url": "https://Domain.zendesk.com/api/v2/ticket_fields/1340584175481.json",
"id": 1340584175481,
"type": "tagger",
"title": "TestField",
"raw_title": "TestField",
"description": "",
"raw_description": "",
"position": 9999,
"active": true,
"required": false,
"collapsed_for_agents": false,
"regexp_for_validation": null,
"title_in_portal": "TestField",
"raw_title_in_portal": "TestField",
"visible_in_portal": false,
"editable_in_portal": false,
"required_in_portal": false,
"tag": null,
"created_at": "2023-03-02T10:55:07Z",
"updated_at": "2023-03-02T10:55:07Z",
"removable": true,
"key": null,
"agent_description": null,
"custom_field_options": [
{
"id": 1340588745617,
"name": "Value1",
"raw_name": "Value1",
"value": "value_1",
"default": false
},
{
"id": 1340588745745,
"name": "Value2",
"raw_name": "Value2",
"value": "value_2",
"default": false
}
]
}
]
Now in order to add a “New Value” we will have to send:
{
"ticket_field": {
"custom_field_options": [
{
"id": 1340588745617,
"name": "Value1",
"raw_name": "Value1",
"value": "value_1",
"default": false
},
{
"id": 1340588745745,
"name": "Value2",
"raw_name": "Value2",
"value": "value_2",
"default": false
},
{
"name":"New Value",
"value":"new_value"
}
]
}
}
The issue what I am facing is when I trying to fetch the data of “Custom_field_options”, it is not a string value but an array. What needs to be done is fetch “custom_field_options”, remove the last square bracket and then append the new value along with square bracket.
I am stuck, can someone please help?