2016-10-19 12 views
0

ITSMのOTRSチケットシステム5を使用しています。チケット、アタッチメントをGeneric Interface(REST)で選択、更新、削除することができます。OTRSレストのチケットの設定項目

私の問題:レストインターフェイスでは、リンクされた構成アイテム(PCなど)ではなく、チケットデータのみが表示されます。私は、LinkObjectのコネクターを追加しなければならないことがわかります私のPerlプログラミングのスキルは、自分でそれを構築するのに十分ではありません、誰かが私に機能的な解決策を得る方法を教えてくれますか?検索と試みるの2週間後、私は、誰かが過去に問題を解決している願っています:)

ここでは内部サーバーエラーを生成している私の私のPerlモジュール(LinkAddの例はHow to Link/Get Config Item to an Ticket through Webservice (SOAP or REST) in OTRSからです):

の下で/Custom/Kernel/GenericInterface/Operation/LinkObject/LinkList.pm

# -- 
# Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm - GenericInterface LinkAdd operation backend 
# Copyright (C) 2016 ArtyCo (Artjoms Petrovs), http://artjoms.lv/ 
# -- 
# This software comes with ABSOLUTELY NO WARRANTY. For details, see 
# the enclosed file COPYING for license information (AGPL). If you 
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. 
# -- 

package Kernel::GenericInterface::Operation::LinkObject::LinkList; 

use strict; 
use warnings; 

use Kernel::GenericInterface::Operation::Common; 
use Kernel::System::LinkObject; 
use Kernel::System::VariableCheck qw(IsStringWithData IsHashRefWithData); 

=head1 NAME 

Kernel::GenericInterface::Operation::LinkObject::LinkList - GenericInterface Link List Operation backend 

=head1 SYNOPSIS 

=head1 PUBLIC INTERFACE 

=over 4 

=cut 

=item new() 

usually, you want to create an instance of this 
by using Kernel::GenericInterface::Operation->new(); 

=cut 

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

    my $Self = {}; 
    bless($Self, $Type); 

    # check needed objects 
    for my $Needed (
     qw(DebuggerObject WebserviceID) 
     ) 
    { 
     if (!$Param{$Needed}) { 
      return { 
       Success  => 0, 
       ErrorMessage => "Got no $Needed!" 
      }; 
     } 

     $Self->{$Needed} = $Param{$Needed}; 
    } 

    # create additional objects 
    $Self->{CommonObject} = Kernel::GenericInterface::Operation::Common->new(%{$Self}); 
    $Self->{LinkObject} 
     = $Kernel::OM->Get('Kernel::System::LinkObject'); 

    return $Self; 
} 

=item Run() 

Create a new link. 

    my $Result = $OperationObject->Run(
     Data => { 
      SourceObject => 'Ticket', 
      SourceKey => '321', 
      TargetObject => 'Ticket', 
      TargetKey => '12345', 
      Type   => 'ParentChild', 
      State  => 'Valid', 
      UserID  => 1, 
     }, 
    ); 

    $Result = { 
     Success  => 1,        # 0 or 1 
     ErrorMessage => '',        # In case of an error 
     Data   => { 
      Result => 1,         # 0 or 1 
     }, 
    }; 

=cut 

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

    # check needed stuff 
    if (!IsHashRefWithData($Param{Data})) { 
     return $Self->{CommonObject}->ReturnError(
      ErrorCode => 'LinkList.MissingParameter', 
      ErrorMessage => "LinkList: The request is empty!", 
     ); 
    } 



    my $LinkID = $Self->{LinkObject}->LinkList(
     %Param, 
    ); 

    if (!$LinkID) { 
     return $Self->{CommonObject}->ReturnError(
      ErrorCode => 'LinkList.AuthFail', 
      ErrorMessage => "LinkList: Authorization failing!", 
     ); 
    } 

    return { 
     Success => 1, 
     Data => { 
      Result => $LinkID, 
     }, 
    }; 
} 

1; 

=back 

=head1 TERMS AND CONDITIONS 

This software is part of the OTRS project (L<http://otrs.org/>). 

This software comes with ABSOLUTELY NO WARRANTY. For details, see 
the enclosed file COPYING for license information (AGPL). If you 
did not receive this file, see L<http://www.gnu.org/licenses/agpl.txt>. 

=cut 
+2

あなたは、少なくともあなたの現在のPerlコードか、少なくとも盗んかのサンプルを表示する必要がありますチケットデータ。どのperlモジュールを使用していますか? –

+0

コードが追加されました。 – Sienael

答えて

0

は、あなたの問題がまだアクティブか? それが提供されている場合、提供されたリンクを見てください: How to Link/Get Config Item to an Ticket through Webservice (SOAP or REST) in OTRS私のコメントperlモジュール。ただキーを返す

my $LinkList = $LinkObject->LinkList(
    Object => 'Ticket', 
    Key  => '321', 
    Object2 => 'FAQ',   # (optional) 
    State  => 'Valid', 
    Type  => 'ParentChild', # (optional) 
    Direction => 'Target',  # (optional) default Both (Source|Target|Both) 
    UserID => 1, 
); 

my $LinkList = $LinkObject->LinkListWithData(
    Object       => 'Ticket', 
    Key        => '321', 
    Object2       => 'FAQ',   # (optional) 
    State       => 'Valid', 
    Type       => 'ParentChild', # (optional) 
    Direction      => 'Target',  # (optional) default Both (Source|Target|Both) 
    UserID       => 1, 
    ObjectParameters    => {    # (optional) backend specific flags 
     Ticket => { 
      IgnoreLinkedTicketStateTypes => 0|1, 
     }, 
    }, 
); 

他2名: は、少なくとも、LinkObjectを実装するためのいくつかのメソッドを持っています。 私はLinkListWithDataを使用し、接続されたCIに関する完全な情報を返します。

また、私は$自己を作成する権利を持ついくつかの問題があると言わなければならない - それは助けて> {LinkObject} 使用しようとする代わりに

# create additional objects 
$Self->{CommonObject} = Kernel::GenericInterface::Operation::Common->new(%{$Self}); 
$Self->{LinkObject} = $Kernel::OM->Get('Kernel::System::LinkObject'); 

この1

local $Kernel::OM = Kernel::System::ObjectManager->new(%{$Self}); 
$Self->{LinkObject} = $Kernel::OM->Get('Kernel::System::LinkObject'); 

を。あなたがLINKLISTメソッドを呼び出すと にhestitate、していない、あなたは%のParamを置くが、地図では、あなたのフィールド(またはHashMapのは、perlで正確に知らない)$ Paramの{データ}、そうも

my $Links = $Self->{LinkObject}->LinkListWithData(
    'Object' => $Param{Data}{Object}, 
    'Key' => $Param{Data}{Key}, 
    'Type' => $Param{Data}{Type}, 
    'Object2' => $Param{Data}{Object2}, 
    'State' => $Param{Data}{State}, 
    'UserID' => $Param{Data}{UserID}, 
); 

を使用するようにしてください(OTRSユーザーがファイルを作成することができ、SHUREを作成し、それへの書き込み)ダンパーとfileappenderのような失礼なデバッグ出力を行います。

my $outfile = '/opt/otrs/var/log/otrs.log'; 
my $timestamp = localtime(time); 
open(my $file_handle, '>>', $outfile) or die "Can't write to file '$outfile' [$!]\n"; 
print $file_handle "$timestamp\n"; 
print $file_handle "=====Custom LinkList started=====\n"; 
my $tempobjectdump = Dumper $Self; 
print $file_handle $tempobjectdump; 

while (my ($key, $value) = each($Param{Data})) { 
    print $file_handle "$key => $value\n"; 
} 
関連する問題