How to Create osTicket Through API ?

How to Create osTicket Through API?

Today I show you how to create a ticket through API in OSTicket and how to create API key In OSTicket.

The osTicket allows third-party applications to automatically open tickets with the service. OSTicket is a free, open-source support ticket system capable of handling inquiries created using emails, web forms on a single platform.

Create API key for authentication:-

API key must be required to create a ticket through API.

Create API key:-

Step 1:

Login OSTicket Admin panel.

Step 2:

Goto  Admin panel – > Manage -> API Keys -> Add New API Key

After click adds new API key step 3 form open and set all details like server Ip address and can create a ticket or can execute cron.

Step 3:-

Set all fields like below Image and click API key Button.

After successfully you can see below message.

What changes needed to create a ticket through API.

Step1 :

Goto Your OSTicket install directory like www.osticket.example/scripts/.

In the scripts folder, You need to edit The Api_ticket_create.php File.

Step 2:

Edit $config array to your URL and your API key.

 

In config array change URL To  Your Domain Name or Your install path like www.example.com/upload/api/http.php/tickets.json and also change key to your generated Key like F235Dg37G4445463DF44354.

NOTE: if you are using subdirectory so you can write URL like this http://Yourdomain/Subfolder/Subfolder/upload/api/http.php/tickets.json

NOTE: If your data is JSON format so write URL End with like  Tickets.json And if your data in XML format so write URL end with like tickets.xml.

Step 3:

set customer data array to all required fields with its values.

Data Array like this

$data= array (

‘Name’ => ’Test Data’, //It’s testing name so you can write your customer name.

‘Email_address’ => ’test@gmail.com’, //It’s testing email so you can write your customer email address.

// Write More fields If required fields available.

);

Error Possible causes and solutions :

If you call Api_ticket_create.php and get a response

unable to create a ticket: unable to create a new ticket: validation errors:
user: Incomplete client information This means any required Fields Missing or invalid data.

Note: – Check your all required field data array exist or not.

If you call Api_ticket_create.php and get response invalid API key means your server Ip address the wrong that time changes your Ip to your server IP address and create new ticket For that server Ip.

Note: – If you get error Invalid API key goto Admin panel ->Dashboard-> System Log And create new API key using System Log Ip  Address.

Leave a comment

PORTFOLIO