Creating Ticket::Article via API - Pundit::NotAuthorizedError

Infos:

  • Used Zammad version: 6.1.0
  • Used Zammad installation type: package
  • Operating system: ubuntu 22.04

Hi, I’m trying to migrate to Zammad and I’m importing our old ticketing system (Kayako Classic) using the Zammad API. I’ve imported all organizations/users/tickets and am now importing ticket articles. I’m using the on-behalf-of feature. So far it works really nice!

175k Ticket::Articles have been created so far, 2k are having issues.

The problem I have, is that I have this ticket belonging to User A, Organization A that somewhere in the line CC’ed User B belonging to Organization B. That User B is a consultant for multiple Organizations.
Whenever I’m trying to import the Article created by User B, I’m getting:

I, [2023-10-05T14:05:07.013642#1031-1055591080]  INFO -- : Started POST "/api/v1/ticket_articles?expand=true" for 192.168.100.25 at 2023-10-05 14:05:07 +0000
I, [2023-10-05T14:05:07.016574#1031-1055591080]  INFO -- : Processing by TicketArticlesController#create as */*
I, [2023-10-05T14:05:07.016685#1031-1055591080]  INFO -- :   Parameters: {"ticket_id"=>96859, "subject"=>" Some subject", "type"=>"email", "from"=>"user_b@organization_b.com", "to"=>"", "created_by_id"=>23586, "updated_by_id"=>23586, "created_at"=>"2019-11-21T12:13:00.000+01:00", "updated_at"=>"2019-11-21T12:13:00.000+01:00", "content_type"=>"text/plain", "body"=>"[FILTERED]", "expand"=>"true"}
I, [2023-10-05T14:05:07.186288#1031-1055591080]  INFO -- : Authentication against Auth::Backend::Internal for user admin@my-org.com ok.
I, [2023-10-05T14:05:07.222236#1031-1055591080]  INFO -- : not allowed to create? this Ticket (Pundit::NotAuthorizedError)
app/controllers/application_controller/authorizes.rb:10:in `authorize!'
app/controllers/ticket_articles_controller.rb:82:in `create'
app/controllers/application_controller/has_download.rb:17:in `block (4 levels) in <module:HasDownload>'
app/controllers/application_controller/has_download.rb:16:in `block (3 levels) in <module:HasDownload>'
app/controllers/application_controller/has_download.rb:15:in `block (2 levels) in <module:HasDownload>'
app/controllers/application_controller/handles_transitions.rb:16:in `handle_transaction'
I, [2023-10-05T14:05:07.222838#1031-1055591080]  INFO -- : Not authorized (Exceptions::Forbidden)

I’m getting the exact same error for other tickets, where the User B doesn’t belong to an organization, but is present in the communication from the old ticketing system.

I can resolve this issue, by changing the Organization to A of User B, import the Article and change it back. However, I don’t think this is a good solution. I’m not sure why I’m getting this Exception or how to solve it correctly.

Any guidance / explanation would be greatly appreciated!

Kind regards,
TvL2386

Please ensure that the user you’re using is allowed to actually write to all groups. Otherwise this process is most likely going to fail on you.

Also, just in case you don’t already, use Token access authentication over Basic authentication to improve Zammads import performance.

Also the “how” you’re creating the article might be the issue.
There’s a difference if you add an incoming or outgoing mail - especially if you’re doing it in user scope. This may also lead to trouble.

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.