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:
I think, that trouble is here:Can't locate object method "ArticleCreate" via package "Kernel::System::Ticket"
Code: Select all
"TicketObject", "ArticleCreate"
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;
}