Zammad.Client icon indicating copy to clipboard operation
Zammad.Client copied to clipboard

Create ticket article with attachment returns file not found

Open kibernetik542 opened this issue 4 years ago • 1 comments

My code looks like:

                ```
               var userClient = _account.CreateUserClient();
                var ticketClient = _account.CreateTicketClient();
                var user = await userClient.CreateUserAsync(new User
                {
                    Login = dto.Username,
                    FirstName = dto.Username,
                    Active = true
                });
                _account.UseOnBehalfOf(user.Login);

                var ticket = await ticketClient.CreateTicketAsync(
                    new Ticket
                    {
                        Title = dto.Title,
                        GroupId = 1,
                        CustomerId = user.Id,
                        OwnerId = user.Id,
                        OrganizationId = dto.OrganizationId
                    },
                    new TicketArticle
                    {
                        Subject = dto.Title,
                        Body = dto.Body
                    });
                string path = null;
                if (dto.Logo is {Length: > 0})
                {
                    path = Path.GetFullPath(dto.Logo.FileName);
                }

                var article = await ticketClient.CreateTicketArticleAsync(new TicketArticle
                {
                    TicketId = ticket.Id,
                    Body = dto.Body,
                    Subject = dto.Title,
                    Attachments = new List<TicketAttachment>
                    {
                        TicketAttachment.CreateFromFile(path, dto.Logo.ContentType),
                        new TicketAttachment()
                        {
                            Filename = path,
                            MimeType = dto.Logo.ContentType
                        }
                    }
                });


And it always returns file not found, if I will not use TicketAttachment.CreateFromFile it will not return Unprocessible Entity.
File I want to upload simple png image

kibernetik542 avatar Jul 28 '21 10:07 kibernetik542

@kibernetik542 to help you with this add your dto definition

alainseys avatar Aug 31 '21 17:08 alainseys