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

JSON API Documents and AWS intergration

I assume it is not possible to update a Ticket from the API ? I would love to integrate with AMAZON SQS .  Currently I have all help desk requests sent in via e-mail end up on a AWS Queue.  I want to use node to process them and put them into osTicket.  It works for new Tickets but there is no method to provide an update that I'm aware of. 

To bad the API can't detect that a ticket already exists and just update it. 

Sample Code Node.JS JSON Ticket creation from e-mail message.


  • var MailParser = require("mailparser").MailParser;
    var mailparser = new MailParser({
        streamAttachments: false
    var request = require('request');
    var fs = require('fs');

  • fs.readFile('./test.txt', 'utf8', function (err, data) {
        if (err) {
            return console.log(err);
        // setup an event listener when the parsing finishes 
        mailparser.on("end", function (mail_object) {
            console.log("From:", mail_object.from); //[{address:'',name:'Sender Name'}] 
            console.log("Subject:", mail_object.subject); // Hello world! 
            //  console.log("Text body:", mail_object.text); // How are you today?
            var osTicketAttachments = [];
            if (mail_object.attachments) {
                var tmpAttach =  "";
                var tmpFileName = "";
                var tmpFileType ="";
                for (i = 0; i < mail_object.attachments.length; i++) {
                   var tmpAttach = mail_object.attachments[i]
                   //var tmpFileName = '"'+ tmpAttach.fileName +  '"';  //Name with Quotes
                   var tmpFileName =  tmpAttach.fileName //+  ''; 
                   var tmpFileType = "data:" + tmpAttach.contentType +";"+tmpAttach.transferEncoding +","

                 osTicketAttachments.push( {[tmpFileName]  : tmpFileType + tmpAttach.content.toString("base64") })
                  // osTicketAttachments.push( JSON.parse ("'{tmpFileName  :'"+ tmpFileType + tmpAttach.content.toString("base64") +"}"))
                   tmpAttach = {};
                   tmpFileNameee = "";
                url: '', //URL to hit       
                method: 'POST',
                headers: {
                    'X-API-Key': '7BFC4B9103930DD4B'
                //Lets post the following key/values as form
                json: {
                    "name": mail_object.from[0].name,
                    "email": mail_object.from[0].address,
                    "subject": mail_object.subject,
                    "message": "data:text/html;charset=utf-8;" + mail_object.html,
                    "topicId": "1",
                    "attachments": osTicketAttachments        
            }, function (error, response, body) {
                if (error) {
                } else {
                    console.log(response.statusCode, body);
        // send the email source to the parser 
  • You have three posts in this thread, the first post explains what your issue is, somewhat. But what are the last two posts referring to?
  • The last two are just some sample code using Node.js to post to the API. This is my question "I assume it is not possible to update a Ticket from the API ? "  It looks like you can only ADD NEW and not UPDATE using the API.

    I thought the sample code may help some on looking to use NODE.js with osTicket.
  • Q: "I assume it is not possible to update a Ticket from the API ?
    A: Correct..  The Open Ticket API only opens tickets.
Sign In or Register to comment.