Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

How to assigne ticket using create ticket api

Hello guys,

             I am able to create ticket but its only create ticket but i want to assigne ticket to member.I am using following script and adding assign to field but its not working.
#!/usr/bin/php -q
#
# Configuration: Enter the url and key. That is it.
# url => URL to api/task/cron e.g # http://yourdomain.com/support/api/tickets.json
# key => API's Key (see admin panel on how to generate a key)
#

$config = array(
'url'=>'http://domain.org/support/upload/api/http.php/tickets.json',
'key'=>'148DCB0jfjB794788CB1902E8DF906482'
);

# Fill in the data for the new ticket, this will likely come from $_POST.

$data = array(
'name' => 'Nilesh Raut',
'email' => 'nilesh_raut@yahoo.com',
'subject' => 'Yahoo Test mail',
'assign to' => 'emaiId', // here i want to assign ticket.
'message' => 'Please provide credentials',
'ip' => $_SERVER['REMOTE_ADDR'],
'attachments' => array(),
);

/*
* Add in attachments here if necessary

$data['attachments'][] =
array('filename.pdf' =>
'data:image/png;base64,' .
base64_encode(file_get_contents('/path/to/filename.pdf')));
*/

#pre-checks
function_exists('curl_version') or die('CURL support required');
function_exists('json_encode') or die('JSON support required');

#set timeout
set_time_limit(30);

#curl post
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $config['url']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_USERAGENT, 'osTicket API Client v1.7');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Expect:', 'X-API-Key: '.$config['key']));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result=curl_exec($ch);

$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($code != 201)
die('Unable to create ticket: '.$result);

$ticket_id = (int) $result;

# Continue onward here if necessary. $ticket_id has the ID number of the
# newly-created ticket
?> 


How to assigne ticket using Json.
Tagged:

Comments

  • I do not believe that there is a way to assign tickets via the API at this time.
  • Hey ntozier please can you provide list of all api's are provided by osticket.
  • Hi Nilesh,

    Can you post the code of api/tickets.json?
    I have that file but it is empty.
  • @uzairjamal you can get the files from github.

    @
    Nilesh
    the API is really basic right now, and pretty much just allows for opening tickets to my knowledge.
  • I was able to get tickets auto assigned to individual staff members but not teams (yet).  I used a sample file by Andrew Bennett (link) and appended the following $data
    $data = array("alert" => "true",
           "autorespond" => "true",
           "source" => "API",
           "name" => "Angry User",
           "email" => "api@osticket.com",
           "subject" => "Testing API 3",
           "message" => "MESSAGE HERE",
           "assignId" => '1' // THIS IS THE STAFF ID FROM THE DATABASE 'OST_STAFF.STAFF_ID'
    );
  • I cannot get assignid to work on my osTicket v1.10-RC.2, They create a new ticket but the ticket is not assign to a staff person.

    Is they a api for setting department ?

Sign In or Register to comment.