Jump to content
Remitur

OpenTicket API - text formatting issue

Recommended Posts

According to https://developers.whmcs.com/api-reference/openticket/ , it seems that it's possible text formatting using the same syntax available in the ticket web text editor; that's to say, their code sample:

$command = 'OpenTicket';
$postData = array(
    'deptid' => '1',
    'subject' => 'This is a sample ticket',
    'message' => 'This is a **sample** ticket message',
    'clientid' => '1',
    'priority' => 'Medium',
    'markdown' => true,
    'attachments' => base64_encode(json_encode([['name' => 'sample_text_file.txt', 'data' => base64_encode('This is a sample text file contents')]])),
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

$results = localAPI($command, $postData, $adminUsername);
print_r($results);

suggests that "sample" should be bold.
And, if I insert *sample*, it will be italic, and so on...

But (for me) it doesn't work: if I use that syntax, I get exactly the same message, without any text formatting; that's to say, if I specify

$textmessage = $textmessage ."\r\n[Text to display](http://www.example.com)";    
  
$textmessage = $textmessage ."\r\n**bold**\r\n*italic*\r\n### Small header\r\n";

the text I will get in the ticket will be:

Quote

 [Text to display](http://www.example.com)
**bold**
*italic*
### Small header



Am I missing something, or is the doc wrong?

Share this post


Link to post
Share on other sites

Using that example code works for me except the attachment doesn't come in.  The word "sample" is bold as expected though.   What version of WHMCS are you using? 

Share this post


Link to post
Share on other sites
6 hours ago, steven99 said:

What version of WHMCS are you using? 

Tried on my dev environment with 7.6.1 ...    😮

Will do a try on production environment too (even if I can't imagine what may be the possible reason...)

Share this post


Link to post
Share on other sites

My dev that I tested on is 7.6.1 also.  So seems to be something special with your dev setup.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated