Create ticket (POST /api/v2/tickets) endpoint default values are not applied

According to Create ticket endpoint documentation, fields “status”, “priority” and “type” have default values 2, 1 and null correspondingly. But request without these fields results in response with HTTP status 400 Bad Request and error message explaining that these fields are required:

$ curl -u <OUR API KEY>:X -X POST -i https://mahalolife.freshdesk.com/api/v2/tickets -H 'Content-Type: application/json' --data '{"name": "Misha", "email": "mikhail.ulyanich@cruxlab.com", "subject": "Testing", "description": "text"}'
HTTP/2 400 
date: Tue, 01 Sep 2020 14:20:46 GMT
content-type: application/json; charset=utf-8
status: 400 Bad Request
pragma: no-cache
x-request-id: 1926cef6-7106-4a18-9c6e-e38b36db96fa
x-freshdesk-api-version: latest=v2; requested=v2
x-rack-cache: invalidate, pass
cache-control: no-cache, no-store, max-age=0, must-revalidate
x-xss-protection: 1; mode=block
x-ua-compatible: IE=Edge,chrome=1
x-content-type-options: nosniff
expires: Wed, 13 Oct 2010 00:00:00 UTC
set-cookie: _x_w=19; path=/; HttpOnly; secure
x-fw-ratelimiting-managed: true
x-ratelimit-total: 3000
x-ratelimit-remaining: 2970
x-ratelimit-used-currentrequest: 1

{"description":"Validation failed","errors":[{"field":"status","message":"It should be one of these values: '2,3,4,5'","code":"missing_field"},{"field":"priority","message":"It should be one of these values: '1,2,3,4'","code":"missing_field"},{"field":"type","message":"It should be one of these values: 'General Question,Technical Support - Incident / Problem,New Feature Request,Certified Navigator Request'","code":"missing_field"}]}

Specifying values 2 and 1 for “status” and “priority” partially resolves the problem, but null is still considered invalid for “type”:

$ curl -u <OUR API KEY>:X -X POST -i https://mahalolife.freshdesk.com/api/v2/tickets -H 'Content-Type: application/json' --data '{"name": "Misha", "email": "mikhail.ulyanich@cruxlab.com", "subject": "Testing", "description": "text", "status": 2, "priority": 1, "type": null}'
HTTP/2 400 
date: Tue, 01 Sep 2020 14:20:21 GMT
content-type: application/json; charset=utf-8
status: 400 Bad Request
pragma: no-cache
x-request-id: 1d6bd5aa-d1b4-41ca-b1db-dc0a4bc0f433
x-freshdesk-api-version: latest=v2; requested=v2
x-rack-cache: invalidate, pass
cache-control: no-cache, no-store, max-age=0, must-revalidate
x-xss-protection: 1; mode=block
x-ua-compatible: IE=Edge,chrome=1
x-content-type-options: nosniff
expires: Wed, 13 Oct 2010 00:00:00 UTC
set-cookie: _x_w=19; path=/; HttpOnly; secure
x-fw-ratelimiting-managed: true
x-ratelimit-total: 3000
x-ratelimit-remaining: 2971
x-ratelimit-used-currentrequest: 1

{"description":"Validation failed","errors":[{"field":"type","message":"It should be one of these values: 'General Question,Technical Support - Incident / Problem,New Feature Request,Certified Navigator Request'","code":"invalid_value"}]}

We are trying to replicate the “help widget” behavior using this API endpoint and tickets created with widget have no type in web interface:

But /api/v2/tickets API does not allow to create a ticket with type being unset.

Anyway, looks like API documentation does not correspond to real API behavior, because default values described in the docs are not applied. How can one create a ticket with type null?

Mikhail,
Looks like the field Type has been set as a Mandatory field.
The right way to fix this would be to remove the Required when submitting the form check from the config.

It will work with the HelpWidget, when the config has been set to show Simple contact form, instead of the full ticket form.

1 Like