Hitachi Vantara Pentaho Community Forums
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Use cookies with REST Client

  1. #1
    Join Date
    Dec 2013
    Posts
    22

    Default Use cookies with REST Client

    Hello,

    My problem is that I don't know how to use/send/receive cookie information in a REST Client in spoon and to keep the session 'open' (I use Keep-alive in my header). The session information is stored in a cookie to determine my 'current' database.

    Some background information:

    I have to connect to an API where the process is as follows:


    • Connect to the API via: http://[someurl]/databases. In return I get an XML response with all my databases;
    • Next I want to set a database as the current database. This is done bij doing http://[someurl]/setdefault?db=[dbcode]&otherkey=[othervalue]. The result is that a cookie file is filled with some session data;
    • Now i can get data from the API using the cookie and a topic like 'Accounts' so something like this: http://[someurl]/getdata?topic=[sometopic].


    In PHP / cURL this all works fine using the curl_setopt($ch, CURLOPT_COOKIEJAR, cookie.txt)

    In spoon, I can:


    • Get a connection to receive the databases;
    • Get data from a topic but only from the database that is set as 'current' (note that if you don't send any session information the server apparently has a 'current' database set).


    Do you have some suggestions on this?

    Thanks a lot.

    Regards,

    kwv

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    There is no automatic cookie handling in my REST Client (4.4.0).
    I had to modify the code so response headers are returned in a field.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Apr 2011
    Posts
    159

    Default

    any way to handle cookies in 5.0?

    the REST application I am interfacing with relies on cookies for future auth requests. I have a transformation that logs in via REST (http://ip/rest/login, POST, JSON) and that passes ok, but then I cannot make future (subsequent) REST calls - they fail with unauthorized because the server is expecting 'a browser' experience (not sure how to word that).

    I spoke with the developers and while there are future plans to changes this cookie-reliance, it (obviously) does not help now.

    Summing up: how can I create a 'cookie' experience in KETTLE while interfacing with a REST service?

    Thanks!!

  4. #4
    Join Date
    Jun 2014
    Posts
    1

    Default

    I'm in the same boat - currently we have web services where I need to extract a cookie from the initial authentication negotiations. I can do that successfully with custom Java code in a UDJC step (I used Jersey vs Apache HTTP, in this case), but without writing yet more custom java code to handle the later operations even things like arbitrarily trying to set a "Cookie:" header fails.

    The only options I see at present are:
    1) Custom Java code via UDJC
    2) Creating a custom Step that extends HTTP Post/Client and deals with cookies

    I'm hoping that "future plans" come to fruition sooner rather than later, otherwise a whole lot of my steps are going to be UDJC and JAR files...

  5. #5
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Well, I made some minor additions to the REST lookup step in Kettle version 4.4.
    Since I didn't want to fiddle with the GUI, I introduced a parameter to hold the output fieldname for the headers.
    Round about ten lines of code I had to add.
    You can run a diff or just look out for the marker AR-1.
    Attached Files Attached Files
    So long, and thanks for all the fish.

  6. #6
    Join Date
    Apr 2011
    Posts
    159

    Default

    Cool!

    Rookie Question - how do I use/load this?

  7. #7
    Join Date
    Mar 2013
    Posts
    148

    Default

    Hi Marabu,

    How do i use this code in PDI. Can you please help

    Quote Originally Posted by marabu View Post
    Well, I made some minor additions to the REST lookup step in Kettle version 4.4.
    Since I didn't want to fiddle with the GUI, I introduced a parameter to hold the output fieldname for the headers.
    Round about ten lines of code I had to add.
    You can run a diff or just look out for the marker AR-1.

  8. #8
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Obviously you must build Kettle from source if you want to use my patches.
    So long, and thanks for all the fish.

  9. #9
    Join Date
    Mar 2013
    Posts
    148

    Default

    How to integrate your source code to handle the session cookie. I am not aware of java can you please help me out.

    Quote Originally Posted by marabu View Post
    Obviously you must build Kettle from source if you want to use my patches.

  10. #10
    Join Date
    Nov 2014
    Posts
    2

    Default

    Hi marabu, is your code already available in PDI 5.1.0 CE? Trying to pass JSESSIONID from the HTTP Response to downstream transformations, but having no docs/release-info..

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.