Custom Fields preventing Ticket creation in API

:point_right: 1. Describe the challenge that you are facing:

I’m new to the API, and have had lots of learning and reading to do.

Firstly I noticed that I could connect tot he API and request information, and that worked fine.

Creating tickets always failed.

Initially I thought it was a permissions issue, but having reviewed my permissions, I have full admin/play permissions god to everything.

I installed Postman having read through some other topics here, and narrowed down the issue.

We have several custom “Manditory” fields for creating tickets.

These Manditory fields are important to me, and I would like to included them when using the API to create tickets.

I’ve tried including these fields as form data, with keys and values, but they are not accepted. It complains that these 3 x fields are unexpected and invalid.

{
“description”: “Validation failed”,
“errors”: [
{
“field”: “country”,
“message”: “Unexpected/invalid field in request”,
“code”: “invalid_field”
},
{
“field”: “ticket_destination”,
“message”: “Unexpected/invalid field in request”,
“code”: “invalid_field”
},
{
“field”: “ticket_type”,
“message”: “Unexpected/invalid field in request”,
“code”: “invalid_field”
}
]
}

If I don’t include those 3 x fields, it complains that they were expected, and should have one fo the following values. (So it is expecting them to be included)

Response:
{
“description”: “Validation failed”,
“errors”: [
{
“field”: “ticket_destination”,
“message”: “It should be one of these values: ‘IT,Finance,Grant Compliance,Facilities,Dynamics 365 CRM,Dynamics 365 GMS,Data Protection’”,
“code”: “missing_field”
},
{
“field”: “country”,
“message”: “It should be one of these values: ‘Afghanistan,Bangladesh,Burkina Faso,Burundi,CAR,Chad,DPRK,DRC,Ethiopia,Haiti,Iraq,Ireland,Kenya,Lebanon,Liberia,Malawi,Niger,Pakistan,Republic of Sudan,Sierra Leone,Somalia,South Korea,South Sudan,Syria,Turkey,UK,Ukraine,USA,Rwanda,Yemen’”,
“code”: “missing_field”
},
{
“field”: “ticket_type”,
“message”: “It should be one of these values: ‘Issue,Query,Request,Invalid,Proactive’”,
“code”: “missing_field”
}
]
}

As I hadn’t created a ticket successfully yet, I followed steps from another topic, and created a business rule, not to mandate those fields when “I” create a ticket.

I am able to create tickets now, which I positive.

However I need to be able to include those 3 x custom fields when creating a ticklet.

Success looks like this:

{
“ticket”: {
“planned_start_date”: null,
“planned_end_date”: null,
“planned_effort”: null,
“subject”: “DM API TICKET CREATE3”,
“group_id”: 50000033522,
“department_id”: 50000069156,
“category”: “Network”,
“sub_category”: “User Account”,
“item_category”: “Leaver”,
“requester_id”: 50004624510,
“responder_id”: null,
“due_by”: “2024-10-01T08:27:13Z”,
“fr_escalated”: false,
“spam”: false,
“email_config_id”: null,
“fwd_emails”: ,
“reply_cc_emails”: ,
“cc_emails”: ,
“is_escalated”: false,
“fr_due_by”: “2024-09-27T12:27:13Z”,
“id”: 108147,
“priority”: 2,
“status”: 2,
“source”: 3,
“created_at”: “2024-09-27T08:27:13Z”,
“updated_at”: “2024-09-27T08:27:13Z”,
“workspace_id”: 2,
“requested_for_id”: 50004624510,
“to_emails”: null,
“type”: “Incident”,
“description”: “

DM API Ticket create3
”,
“description_text”: “DM API Ticket create3”,
“custom_fields”: {
“concern_country_ou”: null,
“country”: null,
“country_iso_num_code”: null,
“country_iso_short_code”: null,
“country_it_teams”: null,
“disabled_accounts_country_ous”: null,
“finance_reporting”: null,
“finance_status”: null,
“gc_location”: null,
“grant_compliance”: null,
“major_incident_type”: null,
“needs_onsite_work”: null,
“purchasing_stage”: null,
“ticket_destination”: null,
“ticket_type”: null,
“business_impact”: null,
“impacted_locations”: null,
“no_of_customers_impacted”: null,
“resolution”: null,
“lf_secondary_agent”: null
},
“tags”: ,
“tasks_dependency_type”: 0,
“resolution_notes”: null,
“resolution_notes_html”: null,
“attachments”:
}
}

I can see the custom fields listed when I create a ticket, but I don’t know how to provide values for them when creating a ticket. It’s not a simple as incliding them as form data, or headers.

I would appreciate some help and guidance from someone more experienced in this. Maybe you’ve seen this or something similar before?

Thanks

Damian

After further reading, I was able to include these fields as form data, by using the following format.

Hello @DamianM I am glad that you were able to figure this out. You definitely need to refer to the custom_fields array of fields when trying to pass them in your request.

I would recommend formatting your request in JSON format as it much more user friendly to read. You can see examples of this format in the Freshservice API Documentation. I am sure you learned a lot troubleshooting the issue yourself. So great work!

1 Like

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.