I have created a Java interface to consume the web service. I can create ticket no problem so far.
My question is that I would like to integrate rich text editor in my program (for the body field), but would like to know how to send rich text to OTRS via web service.
I can retrieve the content from rich text editor (html code + user input words) and send it via TicketCreate in body field. I have set context type as text/plain (OTRS complains about text/html). When I pull the ticket up from OTRS interface, it will show the html code plus user inputs instead of showing formatted text.
How do you send rich text context via web service?
Thank you very much.
how to send rich text in web service
Moderator: crythias
-
- Znuny newbie
- Posts: 6
- Joined: 18 Jun 2015, 15:13
- Znuny Version: 3.3.3-01
- Real Name: Alan Costa de Souza
- Company: Orion Consultoria
- Contact:
Re: how to send rich text in web service
Hi,
I have achieved this today.
You have to use <ContentType>text/html; charset=utf8</ContentType>
and the '<' and '>' have to be replaced by '<' and '>'.
I also had problems with a string ' ' , that represents a space in html, between tags. I just stripped that.
That is my request to the web service:
my $XMLData = '
<UserLogin>'.$userlogin.'</UserLogin>
<Password>'.$userpassword.'</Password>
<Ticket>
<Title>'.$pzabbixsubject.'</Title>
<CustomerUser>'.$smtplogin.'</CustomerUser>
<Queue>zabbix</Queue>
<State>new</State>
<Priority>Contratada</Priority>
<Type>Unclassified</Type>
</Ticket>
<Article>
<Subject>'.$pzabbixsubject.'</Subject>
<From>'.$zabbixemailfrom.'</From>
<Body>'.$zabbixbody.'</Body>
<ArticleType>email-external</ArticleType>
<SenderType>customer</SenderType>
<ContentType>text/html; charset=utf8</ContentType>
<AutoResponseType>auto reply</AutoResponseType>
</Article>
';
and tha is my html body:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SIA - SISTEMA INTELIGENTE DE ATENDIMENTO / ORION CONSULTORIA</title>
<style type="text/css">
body,td,th {
font-family: Geneva;
font-size: 13px;
}
body {
margin-top: 0px;
margin-bottom: 0px;
}
.style02 {
font-size: 17px;
font-family: Geneva;
color: #FFFFFF;
}
.style03 {
font-size: 12px;
font-family: Geneva;
color: #d83e00;
}
#link2 a:hover{
color: #ffff00;
text-decoration: underline;
}
#link2 a { color: #FFFFFF;
text-decoration:none;
}
a:link {
color: #333;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333;
}
a:hover {
text-decoration: underline;
color: #d83e00;
}
a:active {
text-decoration: none;
color: #000;
}
</style>
</head>
<body> '.$zabbixbody.'</body>
</html>
'
}
I have achieved this today.
You have to use <ContentType>text/html; charset=utf8</ContentType>
and the '<' and '>' have to be replaced by '<' and '>'.
I also had problems with a string ' ' , that represents a space in html, between tags. I just stripped that.
That is my request to the web service:
my $XMLData = '
<UserLogin>'.$userlogin.'</UserLogin>
<Password>'.$userpassword.'</Password>
<Ticket>
<Title>'.$pzabbixsubject.'</Title>
<CustomerUser>'.$smtplogin.'</CustomerUser>
<Queue>zabbix</Queue>
<State>new</State>
<Priority>Contratada</Priority>
<Type>Unclassified</Type>
</Ticket>
<Article>
<Subject>'.$pzabbixsubject.'</Subject>
<From>'.$zabbixemailfrom.'</From>
<Body>'.$zabbixbody.'</Body>
<ArticleType>email-external</ArticleType>
<SenderType>customer</SenderType>
<ContentType>text/html; charset=utf8</ContentType>
<AutoResponseType>auto reply</AutoResponseType>
</Article>
';
and tha is my html body:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SIA - SISTEMA INTELIGENTE DE ATENDIMENTO / ORION CONSULTORIA</title>
<style type="text/css">
body,td,th {
font-family: Geneva;
font-size: 13px;
}
body {
margin-top: 0px;
margin-bottom: 0px;
}
.style02 {
font-size: 17px;
font-family: Geneva;
color: #FFFFFF;
}
.style03 {
font-size: 12px;
font-family: Geneva;
color: #d83e00;
}
#link2 a:hover{
color: #ffff00;
text-decoration: underline;
}
#link2 a { color: #FFFFFF;
text-decoration:none;
}
a:link {
color: #333;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333;
}
a:hover {
text-decoration: underline;
color: #d83e00;
}
a:active {
text-decoration: none;
color: #000;
}
</style>
</head>
<body> '.$zabbixbody.'</body>
</html>
'
}