We are having two custom fields created thru admin panel in sherpadesk.From front end add ticket form we are adding custom fields and inserting them thru api.Custom field not showing values in attached screenshot.
Check our code:
if (isset($_POST['classes']) && $_POST['classes']!='') {
$class=$_POST['classes'];
}
if (isset($_POST['child_classes']) && $_POST['child_classes']!='') { //If child class selected,set class as child_class_id
$child_class_id=$_POST['child_classes'];
$class=$child_class_id;
}else{
$child_class_id='';
}
if (isset($_POST['child_child_classes']) && $_POST['child_child_classes']!='') { //If child child class selected,set class as child_child_class_id
$child_child_class_id=$_POST['child_child_classes'];
$class=$child_child_class_id;
}else{
$child_child_class_id='';
}
$data_array=array(
"status" => "open",
"subject" => $subject,
"initial_post" => $initial_post,
"class_id" => $class,
"account_id" => $account_id,
"location_id" => $location_id,
"user_id" => $user_id,
"tech_id" => $technicians,
"ctl00$PageBody$ctl02"=> $tc_ticket_no,//customfield 1
"ctl00$PageBody$ctl04"=> $tp_name,////customfield 2
);
$URL='https://'.ORG_KEY.'-'.INSTANCE_KEY.':'.API_KEY.'@api.sherpadesk.com/tickets/';//API URL
$make_call = callAPI('POST', $URL ,json_encode($data_array));//Function to call api url using CURL and return json response
$response = json_decode($make_call, true);//Convert json response into php array
if (!empty($response)) {
header('location:success.php');
} else {
echo "
";
}
// CURL API call
function callAPI($method, $url, $data){
$curl = curl_init();
switch ($method){
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// OPTIONS:
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('APIKEY:'.API_KEY,'Content-Type: application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// EXECUTE:
$result = curl_exec($curl);
if(!$result){die("Connection Failure");}
curl_close($curl);
return $result;
}
Hi,
see update ticket and
https://github.com/sherpadesk/api/wiki#update-ticket-custom-fields
you need to create xml string
<root><field id="1"><caption>Have You Rebooted?</caption><value>Yes</value></field></root>
where id - is custom field id, and value
see example in mobile site (this is good examples of using api)

--
You received this message because you are subscribed to the Google Groups "SherpaDesk API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sherpadesk-ap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sherpadesk-api/BYAPR04MB5864C2858A7A10E3440EF8BDC9AB0%40BYAPR04MB5864.namprd04.prod.outlook.com.