Created ticket doesn't parse HTML in the description field, outputs everything as plain text



	foreach($orderItems as $orderItem){
                       $orderItemsAsString .= "<p>" .$orderItem->get_name(). "  " . $orderItem->get_quantity() . "  <a>". $orderItem->get_meta('pa_url', true) . "</a></p>";	
			$orderItemsAsString .= "<p> via " . $paymentMethod. "</p>";
			$orderItemsAsString .= "<p> Total {$order->get_total()}</p>";
			// Freshdesk ticket creation
			$fd_domain = "";
			$token = "";
			$password = "";
			$data = array(
				"helpdesk_ticket" => array(
						"description" => $orderItemsAsString,
						"subject" => "PopUSocial New Customer Order (#{$order_id}) ",
						"email" => $order->get_billing_email(),
						"priority" => 1,
						"status" => 2
			// $json_body = json_encode($data, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
			$json_body = json_encode($data);
			$header[] = "Content-type: application/json";
			$connection = curl_init("$fd_domain/helpdesk/tickets.json");
			curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($connection, CURLOPT_HTTPHEADER, $header);
			curl_setopt($connection, CURLOPT_HEADER, false);
			curl_setopt($connection, CURLOPT_USERPWD, "$token:$password");
			curl_setopt($connection, CURLOPT_POST, true);
			curl_setopt($connection, CURLOPT_POSTFIELDS, $json_body);
			curl_setopt($connection, CURLOPT_VERBOSE, 1);
			$response = curl_exec($connection);


As you can see above, I am constructing the order items by adding each order's details inside paragraph tags. When the ticket is created the description isn't properly formatted HTML but plain text that outputs every tag as it is. 

Here's the snapshot of the ticket




Looks like you're trying to use API V1 and I can confirm this from the endpoint on the code - /tickets.json . Can you please update the code based on our API V2 so that the HTML tags are parsed as intended?


My bad. I didn't know about the new version. Thanks for the answer, all is good.

Thanks Jivanysh :) Happy Freshdesk-ing!

Login or Signup to post a comment