Hello,
EDIT: I've narrowed it down to the filename, example #4 works when I hard code a value.
I'm trying to use the AddTicket API to upload files to Lansweeper but I get a Success=False every time, yet the ticket still gets created in Lansweeper and the file is attached to the ticket. The Message from the response is: "Something went wrong. The creation was unsuccessful -> Length cannot be less than zero.\r\nParameter name: length". I get a Success=True if I hard code values. I just change the header string to switch between a failure/success.
Does anyone know what's causing this?
Is this a configuration issue?
Thanks.
Examples of what I see:
1. string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: {3}\r\n\r\n", boundary, "readmetxt", "readme.txt", "text/plain");
Success=True
header=
------------4efd4a7da92e4e66b75f8a5b2f64303d
Content-Disposition: form-data; name="readmetxt"; filename="readme.txt"
Content-Type: text/plain
2. string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: {3}\r\n\r\n", boundary, attachment.Replace(".", string.Empty), attachment, MimeMapping.GetMimeMapping(HostingEnvironment.MapPath("~/Content/Uploads/") + attachment));
Success=False
header=
------------f9de5cb908ec473eaa911b3e66d98823
Content-Disposition: form-data; name="app_offline7htm"; filename="app_offline7.htm"
Content-Type: text/html
3. Same as above, string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: {3}\r\n\r\n", boundary, attachment.Replace(".", string.Empty), attachment, MimeMapping.GetMimeMapping(HostingEnvironment.MapPath("~/Content/Uploads/") + attachment));
Success=False
header=
------------4d9b56d68fd2441eaba50c6c439810dc
Content-Disposition: form-data; name="modelxlsx"; filename="model.xlsx"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
4. string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: {3}\r\n\r\n", boundary, attachment.Replace(".", string.Empty), "random.random", MimeMapping.GetMimeMapping(HostingEnvironment.MapPath("~/Content/Uploads/") + attachment));
Success=True
header=
------------1004f0e9e5e74348b0c310390c9fb0ef
Content-Disposition: form-data; name="readmetxt"; filename="random.random"
Content-Type: text/plain