Forum

Get 'history' info ...
 
Notifications
Retirer tout

Get 'history' info using API

6 Posts
2 Utilisateurs
0 Reactions
4,146 Vu
 Dan
(@caccia)
Posts: 340
Honorable Member
Début du sujet
 
[#3536]

Hello,

For the purpose of automatically generating KPIs on tickets, I would like to extract date/time information on all the different status changes of a ticket.
For the 'major' transitions (creation / handled / done / closed) everything is available in the ticket itself, but I'm not able to retrieve the time of other transitions between states (done -> validated, for example, or any others which don't set a flag).

Would it be possible to get data from a ticket's history using the API ? (all this info is present in the detailed history of the ticket).

Regards.


 
Posté : 19/07/2016 5:56 pm
(@babynus)
Posts: 14952
Membre Admin
 

You can request API upon object History.
criteria will be :
refType='Ticket'
refId=id of ticket
colName='idStatus'


 
Posté : 20/07/2016 2:03 am
 Dan
(@caccia)
Posts: 340
Honorable Member
Début du sujet
 

Thanks, I guess indeed my request syntax was wrong !

I do still have one issue - may very well be a problem at my side, but I want to be sure:
I use as an example: .../api/History/search/refType = "Ticket"/refId = 10146/colName = "idStatus"

==> I use the Chrome extension "Advanced REST Client" for quick tests, and when encoding this string (UrlEncode) I get the following request string:
GET /api/History/search/refType%3D+%22Ticket%22/refId+%3D+10146/colName+%3D+%22idStatus%22

However on the server side, this leads to a syntax error on the MySQL side:

syntax to use near '"Ticket" and refId = 10146 and colName = "idStatus"

If I change the following line in /api/index.php, I do get expected results.

        } else if (count($split)>=2 and $split[1]=='search') { // =============== uri = {OblectClass}/search
...
//                      $where.=urldecode($split[$cpt]);                        //// this line replaced with below line
                        $where.=html_entity_decode($split[$cpt]);
...
        }

However I haven't figured out if "regular usage" of the API (through PHP code) works fine with the current API code.
I do get the same results when simply pasting the request into Chrome address bar.

So not sure if this is an issue, but I thought I'd mention it - worth a check 🙂


 
Posté : 21/07/2016 3:19 pm
(@babynus)
Posts: 14952
Membre Admin
 

Just remove the quotes and spaces

 .../api/History/search/refType=Ticket/refId=10146/colName=idStatus

 
Posté : 21/07/2016 6:08 pm
 Dan
(@caccia)
Posts: 340
Honorable Member
Début du sujet
 

Hmm, that is how I started initially :
.../api/History/search/refType=Ticket/refId=10146/colName=idStatus
=> gets me :
** ERROR ** Exception-[42S22] SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Ticket' in 'where clause'
** ERROR ** For query : select * from history where refType=Ticket and refId=10146 and colName=idStatus and (1=1)

and if I try to add quotes (for the MySQL part):
.../api/History/search/refType='Ticket'/refId=10146/colName=idStatus
or .../api/History/search/refType=%27Ticket%27/refId=10146/colName=idStatus
=> gets me:
** ERROR ** Exception-[42000] SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
** ERROR ** For query : select * from history where refType='Ticket' and refId=10146 and colName=idStatus and (1=1)

Are you able to return expected values with such requests ?


 
Posté : 21/07/2016 6:47 pm
(@babynus)
Posts: 14952
Membre Admin
 

Hi,

This is an issue introduced by security patch on V5.3.
Fix is to replace line 83 in /api/index.php from

    $uri=htmlEncode($_REQUEST['uri']);

to

    $uri=$_REQUEST['uri'];

Fix will be deployed in coming patch V5.4.4


 
Posté : 23/07/2016 3:16 pm
Share:
Retour en haut