Start a new topic
Solved

Unable to create ticket with API v2, Validation Error on Unused / Not Required Field

We're doing some tests to see about creating tickets in Freshservice via the API. However, when doing so, we're receiving a validation error.


The code we're trying through the terminal is as follows:

curl -v -u APIKeyHere:X -H "Content-Type: application/json" -d '{ "description": "Testing creation of a ticket via the Freshservice API", "subject": "[TEST] Ticket creation via API", "email": "existing-contact@email.here", "priority": 1, "status": 2 }' -X POST 'https://domain.freshservice.com/api/v2/tickets'


APIKeyHere = my API Key as obtained through my profile in Freshservice

existing-contact@emai.here = Email Address of an existing contact

domain = our Freshservice subdomain name


When I run the above command, I receive the following error: 

{"description":"Validation failed","errors":[{"field":"department_id","message":"It should be a/an Positive Integer","code":"missing_field"}]}


Looking through the API v2 documentation, "department_id" is not listed as a required field. This particular contact does have a Department/Company associated with the account (as do a majority of our contacts).


If an existing contact has any Departments/Companies added to their record, does that make the department_id field required? Or is this because we have Department/Company as a required field when submitting and close a ticket? (We have this set for both the agents and customers.)

Hi Travis,


Yes, if any field is set to be a mandatory field while creation and if the same is not defined while creating the ticket via API, the validation will fail. Please make sure that all the mandatory fields required for ticket creation are defined while using the API to create a ticket.


Hope this clarifies.

Login or Signup to post a comment
JS Bin