freshworks / fresh-samples

Samples of code created by freshdesk
183 stars 182 forks source link

Not able to create custom fields using PHP #77

Open jimkaler123 opened 2 years ago

jimkaler123 commented 2 years ago

I am using same example code to create ticket with custom fields like below (even checked in Postman):

$custom_fields = array("mobile" => 5788394511 );

$ticket_data = json_encode(array( "description" => "Some details on the issue ...", "subject" => "Support needed..", "email" => "tom@outerspace.com", "priority" => 1, "status" => 2, "cc_emails" => array("ram@freshdesk.com", "diana@freshdesk.com"), "custom_fields" => $custom_fields ));

But I am getting error which says:

{"description":"Validation failed","errors":[{"field":"type","message":"Unexpected/invalid field in request","code":"invalid_field"}]}

Synchro commented 2 years ago

I just ran into this and found a solution. Format them like this:

"custom_fields[mobile]" => "5788394511"