Solved

Error creating ticket with due_by in PHP

I am trying to create a ticket via PHP, however, it is returned an error when trying to create using passing the due_by field.


$ticket_data = json_encode(array(

"description" => "$description",

"subject" => "$subject / REF: #$id_ticket ",

"responder_id" => $agent_id,

"requester_id" => $solicitor_id,

"group_id" => $id_group,

"product_id" => $id_product,

"due_by" => "2017-12-12T23:20:50.52Z",

"source" => $source,

"priority" => 1,

"status" => 2,

"type" => $tipo,

"custom_fields" => $custom_fields

));


The error that returns when given the due_by field:


Error, HTTP Status Code : 400 Headers are HTTP/1.1 400 Bad Request Cache-Control: no-cache, no-store, max-age=0, must-revalidate Content-Type: application/json; charset=utf-8 Date: Wed, 16 Aug 2017 12:11:36 GMT Expires: Wed, 13 Oct 2010 00:00:00 UTC Pragma: no-cache Set-Cookie: _x_w=8; path=/; secure Status: 400 Bad Request X-Freshdesk-API-Version: latest=v2; requested=v2 X-Rack-Cache: invalidate, pass X-RateLimit-Remaining: 4976 X-RateLimit-Total: 5000 X-RateLimit-Used-CurrentRequest: 1 X-Request-Id: 5f43b1a152820eeef9bb358d790dcf59 X-XSS-Protection: 1; mode=block Content-Length: 145 Connection: keep-alive Response are {"description":"Validation failed","errors":[{"field":"fr_due_by","message":"It should not be blank if due_by is given","code":"missing_field"}]}



If you remove the due_by field, in $ ticket_data, the ticket is created normally.


There is something that needs to be done to correct the error.




ADMIN

Hi Thiago,


Your date format has milliseconds also, please make it match to any of the below formats (the list id from the documentation https://developers.freshdesk.com/api/#schema )

YYYY-MM-DD 
YYYY-MM-DDTHH:MM 
YYYY-MM-DDTHH:MMZ 
YYYY-MM-DDTHH:MM:SS 
YYYY-MM-DDTHH:MM:SSZ 
YYYY-MM-DDTHH:MM:SS±hh:mm 
YYYY-MM-DDTHH:MM:SS±hh 
YYYY-MM-DDTHH:MM:SS±hhmm 


Thanks

Mahesh


Login or Signup to post a comment

Sign up for Freshsales today

Start your 30-day free trial. No credit card required. No strings attached.

Start Free Trial