ArticleGet 'Body' deserialization

Moderator: crythias

Post Reply
kruegerM
Znuny expert
Posts: 213
Joined: 02 Dec 2010, 16:53
Znuny Version: 6.0.29
Real Name: Marc
Company: National Jewish Health
Location: Denver, CO

ArticleGet 'Body' deserialization

Post by kruegerM »

I'm trying to use PERL to copy out the Body of an article to use in the creation of a new ticket & article, but getting a 'deserialization' error.
My query in PERL:
my $ArticleObject = $Kernel::OM->Get('Kernel::System::Ticket::Article');
my $ArticleBackendObject = $ArticleObject->BackendForArticle( TicketID => 12345, ArticleID => 54321 );
my %Article = $ArticleBackendObject->ArticleGet (
TicketID => 12345,
ArticleID => 54321,
);
my $bodyCopy = $Article{'Body'};


When I use $bodyCopy in the creation of the article of a new ticket, I get a 500 Internal Server error. The error_log reports the following:
Error deserializing message:not well-formed (invalid token) at line 29, column 39, byte 1179 at /usr/lib64/perl5/vendor_perl/XML/Parser.pm line 187..
RemoteAddress: 127.0.0.1
RequestURI: /otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector

If I print out the XML of the TicketCreate, it looks correct. If I remove $bodyCopy - the ticket creates fine with the article having no body.
Can someone point me to the process to "deserialize" the Body content I'm getting from ArticleGet? Hints appreciated! :)
skullz
Znuny superhero
Posts: 621
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: ArticleGet 'Body' deserialization

Post by skullz »

Wonder why you use Webservice for create/update ticket since you already use the API instead when getting the data. Why not use API also 8)

however, if you using soap webservice, try passing it as CDATA

Code: Select all

<![CDATA[$bodyCopy]]>
good luck
kruegerM
Znuny expert
Posts: 213
Joined: 02 Dec 2010, 16:53
Znuny Version: 6.0.29
Real Name: Marc
Company: National Jewish Health
Location: Denver, CO

Re: ArticleGet 'Body' deserialization

Post by kruegerM »

Good question about just using API. Wish I had a good answer. CDATA is excellent suggestion - if not I may just rewrite this fully under perl API.
Thanks!
Post Reply