Want to send attachements to Telepin Zendesk.

AkashYen007
Tera Guru

Hi Team,

 

I'm newbie to the attachement sending part in Servicenow. I saw few solutions and tried to follow it but not working for me as Zendesk expecting below paramets in the API 

AkashYen007_0-1698042969176.png

I managed to send this till now 

var attachment = new GlideRecord('sys_attachment');
    attachment.addQuery('table_name', current.getTableName());
    attachment.addQuery('table_sys_id', current.sys_id);
    attachment.query();
    while (attachment.next()) {
        sysid = attachment.sys_id;
        size = attachment.size_bytes;
        height = attachment.image_height;
        width = attachment.image_width;
        filename = attachment.file_name;
        contentType = attachment.content_type;
        gs.info('File Name: ' +filename +'\nSize: ' +size +'\nWidth: '+width +'\nHeight:'+height +'\nContent Type:'+contentType);
        try {
            var r1 = new sn_ws.RESTMessageV2('Telepin', 'Post Attachment');
            //r1.setQueryParameter("table_name", attachment.table_name);
            //r1.setQueryParameter("table_sys_id",sysid);
            r1.setQueryParameter('size', size);
            r1.setQueryParameter('height', height);
            r1.setQueryParameter('width', width);
            r1.setQueryParameter("file_name", filename);
            r1.setQueryParameter('id', sysid);
            r1.setRequestHeader("content_type", contentType);
            var response1 = r1.execute();
            var responseBody1 = response1.getBody();
            var httpStatus1 = response1.getStatusCode();
            gs.info('Response Body:' + responseBody1 + '\n Status Code:' + httpStatus1);
            gs.info();
        } catch (ex1) {
            var message1 = ex1.message1;
        }
    }
for above code I'm getting error 422 'Unparsable Attachment error in Servicenow'AkashYen007_1-1698043279649.png

 

I may be wrong understanding this and I'm not able to understand how to send content in base64 to zendesk or send this attachment as a file to zendesk ?
 
1 ACCEPTED SOLUTION

Yes checking with Zendesk community also but was checking if anyone from our community had this same issue or know the solution for this.

Thanks Peter for the help.

View solution in original post

5 REPLIES 5

Peter Bodelier
Giga Sage

Hi @AkashYen007 

 

It looks like you are using the wrong Zendesk API.
This is only for attaching an attachement to a ticket in Zendesk. You'll need to upload it first using the /api/v2/uploads API.

Attachments | Zendesk Developer Docs

For help using this API, I would suggest asking for support in a Zendesk community.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

AkashYen007
Tera Guru

Hi @Peter Bodelier ,

 

Ohh sorry might be wrong example screenshot from zendesk but in RESTMessageV2 'Post Attachment' using the same upload api 

AkashYen007_0-1698048020707.pngAkashYen007_1-1698048040454.png

 

I'm not an Zendesk expert, but I think this post could help you: Attachments | Zendesk Developer Docs

As said I think you should post additional questions there as well, since the complexity seems to be on zendesk side.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Yes checking with Zendesk community also but was checking if anyone from our community had this same issue or know the solution for this.

Thanks Peter for the help.