Invoke error to send data

English! place to talk about development, programming and coding
Post Reply
crynof
Znuny newbie
Posts: 24
Joined: 20 Mar 2020, 20:23
Znuny Version: 6.0
Real Name: Camilo

Invoke error to send data

Post by crynof »

Hello, I am trying to send information about a ticket to an external system.
I have created a module to send that information based on Test.pm (Do not change the name to avoid complications).

When making an event that triggers the sending of data, the console throws the following error.

Image

If I comment the "use strict" the error disappears but when I go to the Invoker debugger, it does not send data or an exit response.

Image

That could be happening?.

My Invoker code it is:

Code: Select all

package Kernel::GenericInterface::Invoker::Test::Test;

#use strict;
use warnings;
use Kernel::System::Ticket;
use Kernel::System::VariableCheck qw(IsString IsStringWithData);

our $ObjectManagerDisabled = 1;

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {};
    bless( $Self, $Type );

    # check needed params
    if ( !$Param{DebuggerObject} ) {
        return {
            Success      => 0,
            ErrorMessage => "Got no DebuggerObject!"
        };
    }

    #$Self->{DebuggerObject} = $Param{DebuggerObject};
	
	$Self->{TicketObject} = Kernel::System::Ticket->new( %Param );

    return $Self;
}

sub PrepareRequest {
    my ( $Self, %Param ) = @_;
	
	my %Ticket = $TicketObject->TicketGet( TicketID => $Param{Data}->{TicketID} );

	return {
			Success => 1,
			Data => {
						%Ticket
					}
			};
}

sub HandleResponse {
    my ( $Self, %Param ) = @_;

    # if there was an error in the response, forward it
    if ( !$Param{ResponseSuccess} ) {
        return {
            Success      => 0,
            ErrorMessage => $Param{ResponseErrorMessage},
        };
    }

    return {
        Success => 1,
        Data    => $Param{Data},
    };
}

1;

Thanks!
skullz
Znuny superhero
Posts: 617
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: Invoke error to send data

Post by skullz »

You didn't define $TicketObject at sub PrepareRequest
crynof
Znuny newbie
Posts: 24
Joined: 20 Mar 2020, 20:23
Znuny Version: 6.0
Real Name: Camilo

Re: Invoke error to send data

Post by crynof »

skullz wrote: 28 Apr 2020, 20:49 You didn't define $TicketObject at sub PrepareRequest
Many Thanks skullz, how can i do that?, exist any example?, I don't know perl.
Cheers
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Invoke error to send data

Post by RStraub »

Hey,

usually I just lookup the Docs or copy from another module. In this case it would be:

Code: Select all

my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
crynof
Znuny newbie
Posts: 24
Joined: 20 Mar 2020, 20:23
Znuny Version: 6.0
Real Name: Camilo

Re: Invoke error to send data

Post by crynof »

RStraub wrote: 29 Apr 2020, 09:26 Hey,

usually I just lookup the Docs or copy from another module. In this case it would be:

Code: Select all

my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
Many Thanks RStraub, finally works.

I was trying send data to Telegram chat, but i dont know how to config invoke on SOAP or REST.

I need to send ticket data to this link (is an example)

https://api.telegram.org/bot933196225:A ... text=Hello

The method sendMessage sends text variable (Hello) to Alerts variable (Chat).

The only way that works (poorly) is paste entire link in Endpoint textbox, but i dont know how to modify that variables to send a Ticket information through text variable, maybe concatenating TicketID, Subject etc etc.

How can do that?

Many thanks again!
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Invoke error to send data

Post by RStraub »

I think there's a part in the manual about how to setup OTRS with a Web Service as Requestor.
So that based on trigger / actions, OTRS does something:

Code: Select all

OTRS as Requester: OTRS acts as a client collecting information, sending the request to the Remote System, and waiting for the response.
From here:
https://doc.otrs.com/doc/manual/admin/6 ... .6.12.4.10
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
crynof
Znuny newbie
Posts: 24
Joined: 20 Mar 2020, 20:23
Znuny Version: 6.0
Real Name: Camilo

Re: Invoke error to send data

Post by crynof »

RStraub wrote: 30 Apr 2020, 08:03 I think there's a part in the manual about how to setup OTRS with a Web Service as Requestor.
So that based on trigger / actions, OTRS does something:

Code: Select all

OTRS as Requester: OTRS acts as a client collecting information, sending the request to the Remote System, and waiting for the response.
From here:
https://doc.otrs.com/doc/manual/admin/6 ... .6.12.4.10
Exactly, as Requester send request to remote system and waiting a response.
My idea is use this request to send data without wait a response. I need a ticket alert system to telegram only.

Exist any method to adapt this request to telegram format?
Many thanks RStraub
Post Reply