API - Create Ticket with custom fields and file attachments.

  • 5 July 2018
  • 0 replies

Hi there,

I have been trying to create a ticket that will have custom fields and file attachments with C#. 

I used the example provided from below link:


However, the example doesn't show me how to convert customs fields to a correct format. so I have been getting the follow data mismatch error:

{"description":"Validation failed","errors":[{"field":"custom_fields","message":"Value set is of type String.It should be a/an key/value pair","code":"datatype_mismatch"}]}

Please see below code implementation and would be much appreciated if someone can let me know what I have done wrong:

 using (var rs = request.GetRequestStream())


writeBoundaryBytes(rs, boundary, false);

writeContentDispositionFormDataHeader(rs, "custom_fields");



private void writeCustomerField(Stream o)


            List<KeyValuePair<string, string>> kvpList = new List<KeyValuePair<string, string>>()


                new KeyValuePair<string, string>("cf_system", "Email Request"),



            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())


                bf.Serialize(ms, kvpList);

                byte[] result = ms.ToArray();

                o.Write(result, 0, result.Length);



This topic has been closed for comments