Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Call RT REST web service to retrieve ticket list

  1. #1

    Default Call RT REST web service to retrieve ticket list

    Hi,

    I have a ticket system based on RT and that also provides retrieving all the data via REST call (https://rt-wiki.bestpractical.com/wiki/REST#Abstract).
    I have used the REST client and HTTP client steps to get the data and always get

    RT/4.0.5 401 Credentials required

    back. Credentials are provided in the steps but I am pretty sure it does not work because of

    Authentication

    The REST Interface does not support HTTP-Authentication. So you must get a valid Session-Token and submit the cookie each request. You usually get a Session-Cookie by submitting the default login form. Use variables "user" for login and "pass" for password values. wget doesn't escape any characters in the --post-data option so make sure you properly escape any special characters in the password.
    See the wget invocation line below:
    wget --keep-session-cookies \
    --save-cookies cookies.txt \
    --post-data 'user=UUUU&pass=PPPP' \
    http://my.rt.server
    You need the -keep-session-cookies option to make wget save session cookies.
    https://rt-wiki.bestpractical.com/wi...Authentication


    So the questions is: how do I get that WGET done in PDI so it creates the cookie first before running that step? Or should I rather try to invoke a CURL request instead?

    Bose
    PDI 7
    Postgres
    Windows 7

  2. #2

    Default

    For reference, I ended up putting it all in a WGET command and saved the output to a text file that I parsed afterwards. Not sexy but it works

    In case somebody needs it later, here the Java Script code to put the whole WGET command together:
    Code:
    //Script here
    
    var wget;
    var output_path;
    var user;
    var password;
    var userString;
    var d = new Date();
    var dString;
    var urlString;
    var outputString;
    
    d.setDate(d.getDate()-1);
    d.setMonth(d.getMonth()+1);
    
    dString = d.getFullYear() + "-" + d.getMonth() + "-" + d.getDate();
    
    user = 'john@gmail.com';
    password = 'Jon373653';
    
    userString = '"user=' + user + '&pass=' + password + '"';
    
    urlString = '"http://ticket.us.int/REST/1.0/search/ticket?query=(Queue=%27AMER%27)%20AND%20(LastUpdated>=%27' + dString + '%27)&orderBy=-Created&format=l&fields=Subject,Status,Created,LastUpdated,Owner,Requestors,CreatedBy,Queue"';
    wget = "C:\\server\\wget.exe";
    output_path = " -O " + export_path + "/rt/rt_download.txt";
    
    outputString = wget + " --keep-session-cookies --save-cookies cookies.txt --post-data " + userString + " " + urlString + output_path;
    PDI 7
    Postgres
    Windows 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.