Create PostMaster Filter via API

Moderator: crythias

Locked
rootuser
Znuny newbie
Posts: 7
Joined: 19 Feb 2015, 18:35
Znuny Version: OTRS free 4.0.5
Real Name: Tom

Create PostMaster Filter via API

Post by rootuser »

Hello,

I am using the OTRS SOAP API to create users and tickets. I do also need to create PostMaster Filters via API, but it does not seem to work. Does anyone know how to do this, or at least if this can be done via API at all?

Thank you very much!
regards, Tom
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Create PostMaster Filter via API

Post by jojo »

I assume you use the "old" rpc.pl API. So you have to add the needed Backend modules in the code.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
rootuser
Znuny newbie
Posts: 7
Joined: 19 Feb 2015, 18:35
Znuny Version: OTRS free 4.0.5
Real Name: Tom

Re: Create PostMaster Filter via API

Post by rootuser »

Hello,

thank you for your answer!
I assume you use the "old" rpc.pl API
I am not sure what you mean. I was following the OTRS 4.0 API Reference, found here: http://otrs.github.io/doc/api/otrs/stable/index.html
Is there another API that I should know about?
So you have to add the needed Backend modules in the code.
Do you know where I can find examples for that?

Regards, Tom
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Create PostMaster Filter via API

Post by jojo »

ok, you are using direct API access...

Did you checked http://otrs.github.io/doc/api/otrs/stab ... er.pm.html
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
rootuser
Znuny newbie
Posts: 7
Joined: 19 Feb 2015, 18:35
Znuny Version: OTRS free 4.0.5
Real Name: Tom

Re: Create PostMaster Filter via API

Post by rootuser »

Hi,

yes I did. And, as I said, whith the info provided here I was able to use the ticker and customerUser objects so far. But the filters will not work.

Basically, I followed an example I found here at the forum: viewtopic.php?t=2945

If you take the example of creating a ticket:

Code: Select all

$ticket = $client->__soapCall("Dispatch", array("user", "passwort", "TicketObject", "TicketCreate", ... 
For example I changed "TicketObject" and "TicketCreate" to "PMFilterObject" and "FilterList" and used an empty array for parameters. Then I get the response message 'No such Object PMFilterObject!'.

Perhaps there is something I have to know about the object name; in tickets, it is Kernel::System::Ticket, in Filters it is Kernel::System::PostMaster::Filter. So maybe I have to use somthing else than "PMFilterObject" for module name, like "PostMaster::Filter".
Last edited by rootuser on 26 Feb 2015, 16:30, edited 1 time in total.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Create PostMaster Filter via API

Post by jojo »

well, htne you have to digg in the code...
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
rootuser
Znuny newbie
Posts: 7
Joined: 19 Feb 2015, 18:35
Znuny Version: OTRS free 4.0.5
Real Name: Tom

Re: Create PostMaster Filter via API

Post by rootuser »

Hello,


after browsing the file /opt/otrs/bin/cgi-bin/rpc.pl, which is the API entry point script, I found the following code lines:

Code: Select all

   $CommonObject{ConfigObject}          = $Kernel::OM->Get('Kernel::Config');
    $CommonObject{CustomerCompanyObject} = $Kernel::OM->Get('Kernel::System::CustomerCompany');
    $CommonObject{CustomerUserObject}    = $Kernel::OM->Get('Kernel::System::CustomerUser');
    $CommonObject{EncodeObject}          = $Kernel::OM->Get('Kernel::System::Encode');
    $CommonObject{GroupObject}           = $Kernel::OM->Get('Kernel::System::Group');
    $CommonObject{LinkObject}            = $Kernel::OM->Get('Kernel::System::LinkObject');
    $CommonObject{LogObject}             = $Kernel::OM->Get('Kernel::System::Log');
    $CommonObject{MainObject}            = $Kernel::OM->Get('Kernel::System::Main');
    $CommonObject{PIDObject}             = $Kernel::OM->Get('Kernel::System::PID');
    $CommonObject{QueueObject}           = $Kernel::OM->Get('Kernel::System::Queue');
    $CommonObject{SessionObject}         = $Kernel::OM->Get('Kernel::System::AuthSession');
    $CommonObject{TicketObject}          = $Kernel::OM->Get('Kernel::System::Ticket');
    $CommonObject{TimeObject}            = $Kernel::OM->Get('Kernel::System::Time');
    $CommonObject{UserObject}            = $Kernel::OM->Get('Kernel::System::User');
Obviously, postmaster or filter is missing. So I simply added:

Code: Select all

$CommonObject{FilterObject}          = $Kernel::OM->Get('Kernel::System::PostMaster::Filter');
which is working perfectly.

I hope that some of you can use this piece of information!

Regards, Tom
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Create PostMaster Filter via API

Post by jojo »

that was my first question if you are using rpc.pl which you denied..
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
rootuser
Znuny newbie
Posts: 7
Joined: 19 Feb 2015, 18:35
Znuny Version: OTRS free 4.0.5
Real Name: Tom

Re: Create PostMaster Filter via API

Post by rootuser »

Hi,

sorry, but I did not deny it.
Instead I asked if there was something newer I need to know of.
I am sorry if that was confusing....

Anyway then: yes, I am using rpc.pl.
But please tell me now: what would be the "new" way you mention indirectly? :)

Thanks, Tom
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Create PostMaster Filter via API

Post by jojo »

there is the generic interface which actually only provide methos for ticket and CI generation. rpc.pl is direct, not abstracted connection to the OTRS API.

You also could use the API directly via perl script, without using SOAP...
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
rootuser
Znuny newbie
Posts: 7
Joined: 19 Feb 2015, 18:35
Znuny Version: OTRS free 4.0.5
Real Name: Tom

Re: Create PostMaster Filter via API

Post by rootuser »

Hello,

I still have a small problem with the filters in OTRS.
When I go to Admin -> Postmaster-Filter, I can see my list of filters (I have 3 right now).

But when I call the FilterList API method, I get a list like the following:

Code: Select all

Array
(
    [s-gensym1929] => checkout
    [s-gensym1931] => checkout
    [s-gensym1933] => Testfilter
    [s-gensym1935] => Testfilter
    [s-gensym1937] => Client A
    [s-gensym1939] => Client A
)
In other words: each filter is listed twice. Why is that?
It is no coding error on the client side, for you can see I get decent IDs in the answer (like s-gensym1929).

Any suggestions?

Thank you very much!
Locked