HTTP Request (UipPath.Web.Activities.HttpClient) with more than one attachment for Freshdesk API

Short update on that.

I unfortunately got no reply from FD support yet to confirm how it works.
But I tried around a bit with the API and the only way it works, is to name all attachments the same.

So I decided to go for Invoke Code and came up with this working thingy:

  Dim client As System.Net.Http.HttpClient = New System.Net.Http.HttpClient()
  client.BaseAddress = New Uri(EndPoint)
  client.DefaultRequestHeaders.Accept.Clear()
  client.DefaultRequestHeaders.Accept.Add(New System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"))
  client.DefaultRequestHeaders.Authorization = New System.Net.Http.Headers.AuthenticationHeaderValue("Basic", auth)
  
  Dim request As System.Net.Http.MultipartFormDataContent = New System.Net.Http.MultipartFormDataContent("----------------------------" + DateTime.Now.Ticks.ToString("x"))
  request.Add(New System.Net.Http.StringContent(subject), """subject""")
  request.Add(New System.Net.Http.StringContent(email), """email""")
  request.Add(New System.Net.Http.StringContent(description), """description""")
  request.Add(New System.Net.Http.StringContent(email_config_id), """email_config_id""")
  request.Add(New System.Net.Http.StringContent("2"), """status""")
  request.Add(New System.Net.Http.StringContent("1"), """priority""")
  files.ForEach(Sub( f As String) request.Add(New System.Net.Http.StreamContent(System.IO.File.OpenRead(f)), "attachments[]", (New FileInfo(f).Name)))
    
  Dim response As System.Net.Http.HttpResponseMessage = client.PostAsync("", request).Result
  status = response.StatusCode
  result = response.Content.ReadAsStringAsync.Result

So I am happy with what I have now, but the question arises, if the activity should have some rework???

@ppr - Fiddler is not an option, as we are not allowed to install such tools by our IT policy (we also do not have admin rights on our laptops).

1 Like