Create a note-internal using Generic Interface

Moderator: crythias

Locked
lpinho
Znuny newbie
Posts: 26
Joined: 05 May 2016, 19:16
Znuny Version: 50000

Create a note-internal using Generic Interface

Post by lpinho »

Hi,

all, I'm using a rest client to consume services from OTRS, I configured/install the GenericTicketConnectorRest.yml from https://github.com/OTRS/otrs/tree/maste ... ebservices.

And then I used a rest client for .NET to create a ticket for a customer (example: got a call from a client and wanted to create a ticket).

(For future reference,I leave the code here)

Code: Select all

            RestClient rclient = new RestSharp.RestClient("http://server/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST");
            RestRequest request = new RestRequest("/Ticket", Method.POST);
            TicketCreate ticketCreate = new TicketCreate()
            {
                Article = new OTRS_Article() { Body = "This ticket was created automatically to record a P1 event.", From = "myemail@server.com", Subject = string.Format("Ticket {0}",DateTime.Now.ToShortDateString()), ContentType = "text/plain; charset=utf8" },
                Ticket = new OTRS_TicketCreate_Ticket() { CustomerID = "blob", CustomerUser = "blob", Title = "P1 Ticket" , Queue = "Test", QueueType = QueueType.QueueID , StateType = StateType.StateID, State = "open" , Priority = "P1 - Critical", PriorityType = PriorityType.PriorityID },
                UserLogin = "blob",
                LoginType = LoginType.UserLogin,
                Password = "blob",
            };

            request.AddJsonBody(ticketCreate);
            IRestResponse response = rclient.Post(request);
            string reply = response.Content;
This works great, what I need now, is to add a note-internal to the ticket, looking at the API, it doesn't seem possible to add a new article of type note-internal to this ticket using the generic interface.

In the pearl API there's a method https://otrs.github.io/doc/api/otrs/sta ... te.pm.html, I'm I able to call this from a rest client? Or Am I limited to the generic interface?
If not, is there any way I can add a note-internal to a ticket without using the OTRS GUI?

Thanks for your help,

L. Pinho
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Create a note-internal using Generic Interface

Post by jojo »

this is done with the TicketUpdate operation in the GenericInterface
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
lpinho
Znuny newbie
Posts: 26
Joined: 05 May 2016, 19:16
Znuny Version: 50000

Re: Create a note-internal using Generic Interface

Post by lpinho »

Hi jojo,

thanks for the reply,

ok, after your reply, I looked into the Article structure (https://otrs.github.io/doc/api/otrs/3.3 ... le.pm.html) and notice that the Article Type determines if the Article is a note-internal.

In the ticketupdate that is not so obvious to me, I'm still learning.

Thanks again for your help and patience.

L. Pinho
lpinho
Znuny newbie
Posts: 26
Joined: 05 May 2016, 19:16
Znuny Version: 50000

Re: Create a note-internal using Generic Interface

Post by lpinho »

Hi,

I'm sending the information to create a note, no note is created and I'm getting this reply in the client:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at 
 root@localhost to inform them of the time this error occurred,
 and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>

Code: Select all

StatusCode: OK
StatusDescription: This buggy server did not return headers
Debug in OTRS GUI

Communication sequence started (2016-07-14 16:00:26, debug)

Code: Select all

$VAR1 = {
  'CONTENT_LENGTH' => '1061',
  'CONTENT_TYPE' => 'application/json',
  'CONTEXT_DOCUMENT_ROOT' => '/opt/otrs/bin/cgi-bin/',
  'CONTEXT_PREFIX' => '/otrs/',
  'DOCUMENT_ROOT' => '/var/www/html',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'HTTP_ACCEPT' => 'application/json, application/xml, text/json, text/x-json, text/javascript, text/xml',
  'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
  'HTTP_CONNECTION' => 'Keep-Alive',
  'HTTP_HOST' => 'cmf-support',
  'HTTP_USER_AGENT' => 'RestSharp/105.2.3.0',
  'MOD_PERL' => 'mod_perl/2.0.9dev',
  'MOD_PERL_API_VERSION' => '2',
  'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin',
  'PATH_INFO' => '/Webservice/GenericTicketConnectorREST/Ticket/1500',
  'PATH_TRANSLATED' => '/var/www/html/Webservice/GenericTicketConnectorREST/Ticket/1500',
  'QUERY_STRING' => '',
  'REMOTE_ADDR' => '111.111.111.111',
  'REMOTE_PORT' => '4742',
  'REQUEST_METHOD' => 'PATCH',
  'REQUEST_SCHEME' => 'http',
  'REQUEST_URI' => '/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/1500',
  'SCRIPT_FILENAME' => '/opt/otrs/bin/cgi-bin/nph-genericinterface.pl',
  'SCRIPT_NAME' => '/otrs/nph-genericinterface.pl',
  'SERVER_ADDR' => '192.168.126.60',
  'SERVER_ADMIN' => 'root@localhost',
  'SERVER_NAME' => 'support',
  'SERVER_PORT' => '80',
  'SERVER_PROTOCOL' => 'HTTP/1.1',
  'SERVER_SIGNATURE' => '',
  'SERVER_SOFTWARE' => 'Apache/2.4.6 (CentOS) mod_perl/2.0.9dev Perl/v5.16.3',
  'UNIQUE_ID' => 'V4epCjdSBwT60nneGNF-qAAAAAE'
};
Received data by provider from remote system (2016-07-14 16:00:26, debug)

Code: Select all

{"CustomerUserLogin":null,"UserLogin":"user","SessionID":null,"Password":"Password","Item1":null,"Item1ElementName":0,"Ticket":{"Title":"P1 Ticket","Queue":"MyQueue","Type":null,"Service":null,"SLA":null,"State":"open","Priority":"P2 - High","Owner":null,"Responsible":null,"CustomerUser":"Lol","CustomerID":"Custom"},"Article":{"ArticleType":"note-internal","SenderType":null,"From":"xxxx@server.com","Subject":"P1 14/07/2016","ContentType":"text/html; charset=utf8","Body":"Incident report is available at <a href=\"\">P1 document</a>.","HistoryType":null,"HistoryComment":null,"AutoResponseType":null,"TimeUnit":0,"TimeUnitSpecified":false,"NoAgentNotify":null,"ForceNotificationToUserID":null,"ExcludeNotificationToUserID":null,"ExcludeMuteNotificationToUserID":null},"DynamicField":null,"Attachment":null,"TicketNumber":"2016071410000092"}
Detected operation 'TicketUpdate' (2016-07-14 16:00:26, debug)

Code: Select all

No data provided
Incoming data before mapping (2016-07-14 16:00:26, debug)

Code: Select all

$VAR1 = {
  'Article' => {
    'ArticleType' => 'note-internal',
    'AutoResponseType' => undef,
    'Body' => 'Incident report is available at <a href=\"\">P1 document</a>.',
    'ContentType' => 'text/html; charset=utf8',
    'ExcludeMuteNotificationToUserID' => undef,
    'ExcludeNotificationToUserID' => undef,
    'ForceNotificationToUserID' => undef,
    'From' => 'xxxx@server.com',
    'HistoryComment' => undef,
    'HistoryType' => undef,
    'NoAgentNotify' => undef,
    'SenderType' => undef,
    'Subject' => 'P1 14/07/2016',
    'TimeUnit' => 0,
    'TimeUnitSpecified' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' )
  },
  'Attachment' => undef,
  'CustomerUserLogin' => undef,
  'DynamicField' => undef,
  'Item1' => undef,
  'Item1ElementName' => 0,
  'Password' => 'password',
  'SessionID' => undef,
  'Ticket' => {
    'CustomerID' => 'Custom',
    'CustomerUser' => 'Lol',
    'Owner' => undef,
    'Priority' => 'P2 - High',
    'Queue' => 'MyQueue',
    'Responsible' => undef,
    'SLA' => undef,
    'Service' => undef,
    'State' => 'open',
    'Title' => 'P1 Ticket',
    'Type' => undef
  },
  'TicketID' => '1500',
  'TicketNumber' => '2016071410000092',
  'UserLogin' => 'user'
};
Is there something wrong with my request or is the server really not configured correctly?
Can I have more information regarding this error?

Thanks,

L. Pinho
Locked