Creating a reply with a ticket with an attachment works the first time but returns a server error 500 on subsequent tries

We use C# to call the APIs. I was using HttpWebRequest with a multipart boundary when sending attachments & noticed that the first time a reply was submitted with an attachment it worked but subsequent tries received a server error 500 from your api.

{“code”:“internal_error”,“message”:“We’re sorry, but something went wrong.”}

I created a test C# unit test project that creates replies with an attachment in a loop. The first call works, the rest don’t.

I managed to find that the “issue” is IFormFile.CopyToAsync(streamToWriteTo). If I use IFormFile.CopyTo(streamToWriteTo) I never have a problem. To be clear:

Endpoint: /api/v2/tickets/{ticketId}/reply

await file.CopyToAsync(streamToWriteTo); //only works once

file.CopyTo(streamToWriteTo); //always works

I have done extensive debugging. The code to send all requests produces exactly the same request each time, including the multipart form data, so I don’t know why it’s failing. The error is coming from the Freshdesk api.

I created a ticket & provided the test project but no one has been able to tell what exception/error is being generated at your end & I keep being told that it’s down to an outdated Ruby library & I’m not even using Ruby!

Changing the code to not use the Async method is a solution & I’ve changed the code to use HttpClient instead of HttpWebRequest, & that works fine. However I still want to know what the issue is. The code works fine the first time & since subsequent requests are the same so they should work aswell. The error is your end.

I don’t want to post the code here as it contains our auth token & other details. I can email it to a Freshdesk dev or I could possibly remove the sensitive data.