Retrieve StudySubjects from Person ID?

Is there any way through WS (either SOAP or REST) to find of finding which SubjectStudy are associated to Person unique ID?
Tagged:

Comments

  • toskriptoskrip Posts: 240 ✭✭
    To my knowledge there is only the expensive way. Get all the StudySubjects and filter them by PersonID on the client side.

    T
  • giladhosgiladhos Posts: 6
    Hey can I join thread? :)

    I'm trying to get all study subject as said here with GET:
    This is from documentation:
    {Server_Address}:8080/OpenClinica/rest/clinicaldata/json/view/{Study_Name}/*/*/*

    I am getting HTTP 302(found) back, it seems I'm being redirected to OpenClinica/pages/login/login (Location value in response).
    I am asked to answer oAuth2 challenge - 'Www-Authenticate: OAuth2', not sure what to do next, even more confusing is that in more than a few places in documentation it says api_key is the method used in OC.

    If anyone can clear this up would be great.

    Many thanks

  • toskriptoskrip Posts: 240 ✭✭
    Hi,

    the authentication mechanism for existing REST APIs is not harmonised yet (hopefully will be with OC4 on the horisont). RESTful URLs that you are trying to use work with standard user session. You have to emulate user login into OC with POST to OC login and user the stored session for another GET call.

    This I have already described in another post on the forum here:

    REST Call to login to OpenClinica

    best

    T
  • giladhosgiladhos Posts: 6
    edited September 2016
    ok, that's clearing some things up for me.

    I'm still nowhere with it though since I'm not using curl and localhost:8080/OpenClinica/j_spring_security_check gets me the same 302 response. I added j_username and j_password as POST parameters.
    (even tried all combinations with/without "j_" )

    I'm trying to parse with json using java and filter it according to any field the users will choose.

    I did manage to run http://openc1.bgu.ac.il/OpenClinica/pages/login/login and get:
    output said:



    div ID="login">
    form action="/OpenClinica/j_spring_security_check;jsessionid=EF4DAA8D2AC033858C5E0C369105E101" method="post">
    h1>Login
    b>User Name /b>
    div class="formfieldM_BG">
    input type="text" id="username" name="j_username" class="formfieldM">
    /div>
    b>Password
    div class="formfieldM_BG">
    input type="password" id="j_password" name="j_password" class="formfieldM" autocomplete="off">
    /div>
    input type="submit" name="submit" value="Login" class="loginbutton" />
    a href="#" id="requestPassword"> Forgot Password?
    /form>
    br/>
    !-- Alert Box -->
    /div>
    !-- End Login box contents -->Hi,

    *I ruined some of that html so that it stays text*

    from which I can see the address /OpenClinica/j_spring_security_check you were refering to, with method = post .

    Do you know the way for this to wokr correctly?

    Many thanks!
  • toskriptoskrip Posts: 240 ✭✭
    Hi,

    it depends on which HTTP client library you are using. If it is jersey have a look at the last getOcRestfulUrl method of the following helper class:

    OpenClinicaService.java

    basically emulates POST with with login form data in MultivaluedMap. After successful login retrieving the jsessionid and creating a cookie. And than later using this cookie to perform authenticated GET for OC Restful URL.

    T
Sign In or Register to comment.