Get Request don't work for me using requestLibrary: 404 Error

553 views
Skip to first unread message

Habibou MAMAN

unread,
Jun 20, 2018, 8:12:45 AM6/20/18
to robotframework-users
Hi all,

Need help. I try without success to execute a get request AML QC REST API. I got 404 error

I'm novice on robot framework and API.

Below my testcase

*** Settings ***
Library           BuiltIn
Library           Selenium2Library
Library           Dialogs
Library           OperatingSystem
Library           Collections
Library           String
Library           RequestsLibrary

*** Test Cases ***
draft_001
    [Tags]    NOTREADY
    open browser    http://myHost/qcbin/rest/is-authenticated?login-form-required=y    chrome    testauto
    wait until element is visible    //input[@id="j_username"]    5
    input text    //input[@id="j_username"]    myLogin
    input password    //input[@id="j_password"]    myPassword
    click element    //input[@type="submit"]
    ${cook}=    get cookies
    log    ${cook}
    &{Headers}=    create dictionary    Accept=text/html,application/xhtml+xml,application/xml    Accept-Encoding=gzip, deflate    Cookie=${cook}    Host=almqc12
    ${resp}=  Get Request  testauto  http://myHost/qcbin/rest/domains/FORMATION/projects/FORMATION/test-instances/1  ${Headers}
    [Teardown]    Close Browser

Hélio Guilherme

unread,
Jun 20, 2018, 4:17:34 PM6/20/18
to robotframework-users
Well, without having real experience with QC API, here is my contribute:
- The logic you are doing, is to create a session cookie with Chrome, then,
- Use this same cookie to send requests' requests ( :)  )

I think you need to "fake" in requests the user-agent to be the same as Chrome. (I did this with Firefox some years ago)
I think you should not use the same connector (you are already connected). So there should be an alternative to not request the login form
(unless this is the correct URL meaning, "if user is not logged in, then show the form")

Good luck.


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.



--
My Favorite Open Source Projects
awsome-lists gretl meld robotframework wxPython

Habibou MAMAN

unread,
Jun 21, 2018, 5:30:07 AM6/21/18
to robotframework-users
Hello Hélio Guilherme

Thank you for your answer. I tried to modify my request by following your recommandations.
But I still facing the same issue 404 ERROR

- First you told about "Fake" user agent : so I added in the header of my request chrome's user agent. Maybe I don't understand what you mean? Could you give  me an example? 
- Second in creation session I used http://Host/qcbin/rest/is-authenticated  this url is the redirection url after logged in user
-Third when I go to this url  http://Host/qcbin/rest/domains/FORMATION/projects/FORMATION/test-instances/ via browser after logged in api returns result page formated as XML. So I used it in Get Request

Below my test case after modification


*** Test Cases ***
draft_001
    [Tags]    NOTREADY
    wait until element is visible    //input[@id="j_username"]    5
    input text    //input[@id="j_username"]    login
    input password    //input[@id="j_password"]    password
    click element    //input[@type="submit"]
    ${JSESSIONID}=    get cookie value    JSESSIONID
    ${ALM_USER}=    get cookie value    ALM_USER
    ${LWSSO_COOKIE_KEY}=    get cookie value    LWSSO_COOKIE_KEY
    ${QCSession}=    get cookie value    QCSession
    ${XSRF-TOKEN}=    get cookie value    XSRF-TOKEN
    ${cook}=    create dictionary    JSESSIONID=${JSESSIONID}    ALM_USER=${ALM_USER}    LWSSO_COOKIE_KEY=${LWSSO_COOKIE_KEY}           QCSession=${QCSession}    XSRF-TOKEN=${XSRF-TOKEN}
    ${sess}=    create session    testauto    http://Host/qcbin/rest/is-authenticated    cookies=${cook}
    ${Headers}=    create dictionary    Accept=text/html,application/xhtml+xml,application/xml,application/json    Accept-Encoding=gzip, deflate    Host=MyHost   User-Agent=Chrome/66.0.3359.181
    ${resp}=    Get Request    testauto    http://Host/qcbin/rest/domains/FORMATION/projects/FORMATION/test-instances/    ${Headers}
    [Teardown]    Close Browser
To post to this group, send email to robotframe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages