File posting using http plugin.

Hi All,

I am using Zendesk(Support Site) integration Rest API to create new tickets . I could successfully create tickets . I want to send file attachments . I am using the following code to post the file . It is successful . But how can I get the uploaded token ? .I need the token value to refer it along with the tickets . The getPageData() is returning null.

Code Snippet:
var zendeskUploadURL = “https://XXX.zendesk.com/uploads.xml”;
//Put a file at the specified URL.
var fileAdded = plugins.http.put(‘clientName’, zendeskUploadURL, ‘delete_icon_16.png’, ‘C:/Users/ashutosl/Desktop/IMP/delete_icon_16.png’, username, password);
application.output(fileAdded);
application.closeForm();
application.output(plugins.http.getPageData(zendeskUploadURL , ‘clientName’));

Thanks in advance . Waiting for your feedback. Please provide some informations on this.

Thanks,
Ashutos.

Hi All,

I would like to share some more findings . Now I could send the file as attachment along with zendesk ticket. But the content type of the file is getting distorted . I cannot open the file .

Code Snippet:

posterObjAttach.addHeader(‘Content-Type’, ‘image/png’);
var posterObjAttach = plugins.http.getPoster(“https://XXX.zendesk.com/uploads.xml?filename=delete_icon.png”);
var i = posterObjAttach.addFile(‘’,‘delete_icon.png’,‘C:/Users/ashutosl/Desktop/IMP/delete_icon.png’);

please find the attachment api for the following code.
Attachment API:
curl -u username:password -H “Content-Type: application/binary”
–data-binary @somefile.txt
-X POST http://helpdesk.zendesk.com/uploads.xml … mefile.txt

I am using servoy 5.2.11 . Thanks in advance . Waiting for your feedback.

Hi All,

There seems to be a problem with the image file headers . Image files are not supporting. Text files are successfully working . I am getting some headers in the text file like below :

Content-Disposition: form-data; name=“Content”; filename=“A.txt”
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Transfer-Encoding: binary

I am using the following code below for header of image files . I think there is some issue with it . What should be headers for the image file ?.

posterObjAttach.addHeader(‘Content-type’,‘image/png’);

Please provide some informations on this.