Hello Team,
I am trying to create a ticket in Freshdesk along with attachments, but I am getting an error.
The Error is:
TypeError: source.on is not a function
at Function.DelayedStream.create (/usr/local/lib/node_modules/fdk/node_modules/delayed-stream/lib/delayed_stream.js:33:10)
at FormData.CombinedStream.append (/usr/local/lib/node_modules/fdk/node_modules/combined-stream/lib/combined_stream.js:45:37)
at FormData.append (/usr/local/lib/node_modules/fdk/node_modules/request/node_modules/form-data/lib/form_data.js:74:3)
at appendFormValue (/usr/local/lib/node_modules/fdk/node_modules/request/request.js:326:21)
at Request.init (/usr/local/lib/node_modules/fdk/node_modules/request/request.js:337:11)
at new Request (/usr/local/lib/node_modules/fdk/node_modules/request/request.js:127:8)
at Function.request (/usr/local/lib/node_modules/fdk/node_modules/request/index.js:53:10)
at Request._tryUntilFail (/usr/local/lib/node_modules/fdk/node_modules/requestretry/index.js:124:23)
at Factory (/usr/local/lib/node_modules/fdk/node_modules/requestretry/index.js:178:7)
at Object.execute (/usr/local/lib/node_modules/fdk/lib/api/proxy.js:171:12)
My code:
var base64 = require('base-64');
exports = {
events: [{
event: 'onConversationCreate',
callback: 'onConversationCreateHandler'
}],
onConversationCreateHandler: function (args) {
console.log('onConversationCreateHandler event');
test();
}
};
function test() {
console.log("in testttttttttttttt");
var url = "https://xxxxxxxxxxx.freshdesk.com/api/v2/tickets";
var apiKEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var headers = {
"Content-Type": "multipart/form-data",
"Authorization": "Basic " + base64.encode(apiKEY)
};
var a = {
"file": "/home/artis/Music/ask"
};
var formData = {
"description": "support ticket....",
"subject": "support ticket...",
"email": "tcheekati@artissol.com",
"attachments[]": a
};
var options = {
formData: formData,
headers: headers
};
console.log(url);
console.log(options);
$request.post(url, options).then(function (data) {
console.log("sssssssssssssssssssssssssss", data);
}, function (error) {
console.log(error);
});
}
Regards,
Akhil S Kulkarni