Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ticket article with attachment returns file not found #43

Open
kibernetik542 opened this issue Jul 28, 2021 · 1 comment
Open

Comments

@kibernetik542
Copy link

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
@alainseys
Copy link

@kibernetik542 to help you with this add your dto definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants