Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Saju Kumar
    Incident File attachment using SOAP C#Answered
    Topic posted July 18, 2019 by Saju KumarRed Ribbon: 250+ Points, last edited July 18, 2019 
    46 Views, 5 Comments
    Title:
    Incident File attachment using SOAP C#
    Content:

    Hi Everyone,

    I'm new to C# coding and I'm trying to build a RN Soap API C# code for Incident file attachment. I managed to developed C# code for Incident standard, custom fields and custom objects but I struggling in file attachment.

    Can anybody help me with the sample C# code for Incident file attachment?

    I'm looking to attach a file (.txt) when Incident created from outside RN. 

    Thanks

    Saju

    Best Comment

    Saju Kumar

    Incident file attachment using C# Soap API. 

    I have provided static value for file length but you can fetch it from original file and add a for loop will done the trick.

    Incident newIncident = new Incident();

        FileAttachmentIncident[] fileAttachmentIncident = new FileAttachmentIncident[1]; //1 - file length

        fileAttachmentIncident[0] = new FileAttachmentIncident();

        fileAttachmentIncident[0].action = ActionEnum.add;

        fileAttachmentIncident[0].actionSpecified = true;

        fileAttachmentIncident[0].ContentType = "application/pdf";

        fileAttachmentIncident[0].Data = readByteArrayFromFile("c:\\temp\\feb10_css_user_send.pdf");

        fileAttachmentIncident[0].Description = "RightNow CSS User Guide";

        fileAttachmentIncident[0].FileName = "RightNowFeb10CssUser.pdf";

        fileAttachmentIncident[0].Name = "RightNow CSS User Guide";

        newIncident.FileAttachments = fileAttachmentIncident;

     

    Regards,

    Saju

    Comment

     

    • Tushar Gupta

      Hi

      What do you want to do with file attachment? Do you want to get the details of the file attachments of the Incidents / Custom Objects or download the attachments. 

      Thanks

    • Saju Kumar

      Incident file attachment using C# Soap API. 

      I have provided static value for file length but you can fetch it from original file and add a for loop will done the trick.

      Incident newIncident = new Incident();

          FileAttachmentIncident[] fileAttachmentIncident = new FileAttachmentIncident[1]; //1 - file length

          fileAttachmentIncident[0] = new FileAttachmentIncident();

          fileAttachmentIncident[0].action = ActionEnum.add;

          fileAttachmentIncident[0].actionSpecified = true;

          fileAttachmentIncident[0].ContentType = "application/pdf";

          fileAttachmentIncident[0].Data = readByteArrayFromFile("c:\\temp\\feb10_css_user_send.pdf");

          fileAttachmentIncident[0].Description = "RightNow CSS User Guide";

          fileAttachmentIncident[0].FileName = "RightNowFeb10CssUser.pdf";

          fileAttachmentIncident[0].Name = "RightNow CSS User Guide";

          newIncident.FileAttachments = fileAttachmentIncident;

       

      Regards,

      Saju