OSTicket is one of the popular open-source Support Ticket Systems that can be hosted on your Shared-Server or VPS or Dedicated Server and that’s without paying any subscription fee. In this article, we’ve tried to provide you with a solution to some API-related bugs that are not yet patched despite several version releases.
The most common and unresolved issue is when you try to create a new ticket or a new task using the API, the system returns either “No input file specified“, “unsupported input file specified” or “URL not supported“. It is basically .htaccess
rewrite issues and also some bugs within the OSTicket System itself and your web server be it IIS or Apache.
“No input file specified” is a .htaccess
rewrite issue and there are several tweaks discussed on GitHub and OSTicket community
.htaccess
and recommends using an alternative method to resolve the No input file specified issue. You can directly specify the API URL while calling using cURL or any other method; for instance, if you’ve hosted OSTicket at https://support.example.com
then you can simply specify https://support.example.com/api/http.php/tickets.json
instead of https://support.example.com/api/tickets.json
and the same is applicable for task.json
,email.json
and tickets.xml
etc. On the other hand, if you want to correct the .htaccess
rewrite rule, then you can change from RewriteRule ^(.*)$ %1/http.php/$1 [L]
to RewriteRule ^(.*)$ %1/http.php?$1 [L]
.
If you’ve installed the OSTicket on your local machine, then please make sure to generate the OSTicket API Key for localhost (IP address). In some cases, even after specifying the localhost IP address does not work, in that case, you can try another API Key with ::1
IP address. Also, make sure to follow the instruction aforementioned, and checking the OSTicket System log seems to be helpful.
Foremost, if you are using Cloudflare or any other CDN service, then you should whitelist your server’s IP address in your Cloudflare or CDN account. Make sure to whitelist both IPv4 and IPv6 to avoid getting blocked at your CDN level. Other things that you’d to ensure:–
cURL offers "--resolve"
option to stick to a specific IP address and port number. You can utilise this functionality to bypass the proxy and also to force to resolve the hostname against the specified IP address. This can be done by initializing curl_init
with $ch = curl_init('192.168.1.1');
and adding Host to the CURLOPT_HTTPHEADER
header curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: support.example.com', 'Expect:', 'X-API-Key: YOUR-API-KEY'));
Note:– Don’t forget to replace 192.168.1.1
with your Server’s IP, support.example.com with your OSTicket’s hosted sub-domain or domain, and YOUR-API-KEY with your OSTicket’s Key.You should be very careful if you are using attachments and make sure that you are generating a valid base64 code with the proper header. In PHP base64_encode()
removes data:file_mime;base64,
string from the base64 code, that you’ve to handle at your end. You can use the following PHP code to concatenate a valid base64 with the proper MIME header code —
$filetype=$_FILES["fileToUpload"]["type"]; // replace fileToUpload with your input file's name
$base64_doc='data:'.$filetype.';base64,';
$base64_doc.=base64_encode(file_get_contents(getcwd().'/'.$target_dir.$filename));
You can contact us if need any help or have any suggestions regarding the same.