I have been trying to access osTicket api from my meteor code, here's my code so far:
if (Meteor.isServer) {
Meteor.methods({
osTicket: function() {
this.unblock();
return HTTP.post("http://www.xxxxxxxx.com/uploads/api/tickets.json","X-API-Key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
{
data: {
"alert": true,
"autorespond": true,
"source": "API",
"name": "Angry",
"email": "api@osticket.com",
"phone": "3185558634X123",
"subject": "Testing API",
"ip": "172.22.78.114",
"message": "MESSAGE HERE",
"attachments": [{
"file.txt": "data:text/plain;charset=utf-8,content"
}, {
"image.png": "data:image/png;base64,R0lGODdhMAA..."
}, ]
},
},
function(error, results) {
if (results) {
console.log(results);
} else {
console.log(error)
}
}
);
}
});
}
if (Meteor.isClient) {
Template.api.events({
'click #submitQuery': function() {
Meteor.call("osTicket");
}
})
}
I am getting a 200 status and some html code from the api, that means the connection is successful but I am unable to create any ticket from my code by using the api.
So, what am I doing wrong? Is my syntax for connecting with the api correct?
Plz refer to https://github.com/osTicket/osTicket-1.7/blob/develop/setup/doc/api/tickets.md for further info.
Thanks.