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);          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               //var tmpFileName = '"'+ tmpAttach.fileName +  '"';  //Name with Quotes               var tmpFileName =  tmpAttach.fileName //+  '';                tmpFileName.replace('"',"")               var tmpFileType = "data:" + tmpAttach.contentType +";"+tmpAttach.transferEncoding +","             osTicketAttachments.push( {  : tmpFileType + tmpAttach.content.toString("base64") })              // osTicketAttachments.push( JSON.parse ("'{tmpFileName  :'"+ tmpFileType + tmpAttach.content.toString("base64") +"}"))               tmpAttach = {};               tmpFileNameee = "";               tmpFileType="";            }         }        request({            url: 'http://helpdesk.test.com/osticket/upload/api/http.php/tickets.json', //URL to hit                   method: 'POST',            headers: {                'X-API-Key': '7BFC4B9103930DD4B'            },            //Lets post the following key/values as form            json: {                "name": mail_object.from.name,                "email": mail_object.from.address,                "subject": mail_object.subject,                "message": "data/html;charset=utf-8;" + mail_object.html,                "topicId": "1",                "attachments": osTicketAttachments                    }        }, function (error, response, body) {            if (error) {                console.log(error);            } else {                console.log(response.statusCode, body);            }        });    });    // send the email source to the parser     mailparser.write(data);    mailparser.end();});

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?

9 days later

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.

Write a Reply...