[SOLVED] Can't create Article on OTRS 6 - PHP (SOAP)

Moderator: crythias

Post Reply
denisdanilenko
Znuny newbie
Posts: 9
Joined: 23 Oct 2018, 11:37
Znuny Version: 6.0.9
Real Name: Denis Danilenko
Company: AO NTC "EKVIT"

[SOLVED] Can't create Article on OTRS 6 - PHP (SOAP)

Post by denisdanilenko »

Hello.

I have a problem, while creating Article on PHP, using SOAP (OTRS 6.0.*)
I'm using PHP code, which is for OTRS 5 version.
But, as i know, the structure of Articles was changed in OTRS 6 version, so it doesn't work now.
I'm not good understand what was changed.

I can create empty ticket now. But when i try to create article (subject, body,..elements) by tickets ID, i get a mistake:
Can't locate object method "ArticleCreate" via package "Kernel::System::Ticket"
I think, that trouble is here:

Code: Select all

"TicketObject", "ArticleCreate"
or maybe anywhere else.

OTRS is located in server 1, PHP script is located on my website in server 2.

Could you help me, please, to solve this problem?

Thank you.

Code: Select all

public function addArticle(
        $ticketID,
        $createdBy,
        $userID,
        $subject,
        $body,
        $articleType = 'webrequest',
        $from = null,
        $contentType = 'text/plain; charset=ISO-8859-1'
    )
    {

        if (strlen(trim($subject)) == 0) {
            throw new \Exception('Need a subject. Subject is empty');
        }
        if (strlen(trim($body)) == 0) {
            throw new \Exception('Need a body. Body is empty');
        }
        if (strlen(trim($articleType)) == 0) {
            throw new \Exception('Article Type can not be empty.');
        }
        if (!is_int($ticketID)) {
            throw new \Exception('TicketID needs to be an integer');
        }

        $request = [
            "TicketObject", "ArticleCreate",
            "TicketID", $ticketID,
            "ArticleType", $articleType,
            "SenderType", "system",
            "HistoryType", "WebRequestCustomer",
            "HistoryComment", $createdBy,
            "Subject", $subject,
            "ContentType", $contentType,
            "Body", $body,
            "UserID", $userID,

        ];

        switch ($articleType) {
            case 'note-internal':
                $request = array_merge($request, [
                    "NoAgentNotify", 1,
                ]);
                break;
            case 'webrequest':
                $request = array_merge($request, [
                    "Loop", 0,
                    "From", $from,
                    "AutoResponseType", 'auto reply',
                    "OrigHeader", [
                        'From' => $from,
                        'To' => 'Postmaster',
                        'Subject' => $subject,
                        'Body' => $body,
                    ]
                ]);
                break;
        }

        $articleID = $this->send($request);

        return $articleID;
    }
Last edited by denisdanilenko on 30 Oct 2018, 14:03, edited 2 times in total.
root
Administrator
Posts: 3961
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Can't create Article on OTRS 6 - PHP (SOAP)

Post by root »

Hi,

I don't believe you use the GenericInterface SOAP. I'am right when I guess you use the rpc.pl (XML-RPC) endpoint? If yes: stay away from this, is deprecated. Use instead the GenericInterface REST or SOAP. There is no method ArticleCreate in the TicketObject with OTRS 6.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
denisdanilenko
Znuny newbie
Posts: 9
Joined: 23 Oct 2018, 11:37
Znuny Version: 6.0.9
Real Name: Denis Danilenko
Company: AO NTC "EKVIT"

Re: Can't create Article on OTRS 6 - PHP (SOAP)

Post by denisdanilenko »

root wrote: 23 Oct 2018, 18:41 Hi,

I don't believe you use the GenericInterface SOAP. I'am right when I guess you use the rpc.pl (XML-RPC) endpoint? If yes: stay away from this, is deprecated. Use instead the GenericInterface REST or SOAP. There is no method ArticleCreate in the TicketObject with OTRS 6.

- Roy
Hello, Yes, i used rpc.pl, but now i will use GenericInterface SOAP. Thank you very much.
Closed..
Post Reply