0

I am new to Robot Framework and am facing an issue while sending query params in Get Request method. Following is the code that I tried with no luck :

Get Data With Filter
    [Arguments]    ${type}    ${filter}
    ${auth} =    Create List    ${user_name}    ${password}
    ${params} =    Create Dictionary    type=${type}    filter=${filter}
    Create Session    testingapi    url=${some_host_name}    auth=${auth}
    ${resp} =    Get Request    testingapi   /foo/data    params=${params}
    Log  ${resp}

${type} has value new and ${filter} that I want is id:"1234"

I am expecting final url to formed as : /foo/data?type=new&filter=id%3A1234

Instead of forming the expected url, I get the request url as :

GET Request using : uri=/foo/data, params={'type': 'new', 'filter': 'id:1234'}

I might be missing something very obvious but I cant figure out what it is. What can I change in this piece of code or any new code that needs to be added?

1 Answer 1

2

I think the logger is just outputting the params as the dictionary. The request should actually be made to foo/data?type=new&filter=id%3A1234

You can test it with the following request to Postman Echo (An HTTP testing service):

    ${auth} =    Create List    Mark    SuperSecret
    ${params} =    Create Dictionary    type=Condos    filter=2Bedrooms
    Create Session    testingapi    url=http://postman-echo.com    auth=${auth}
    ${resp} =    Get Request    testingapi   /get    params=${params}

    ${json} =  To JSON  ${resp.content}  pretty_print=True
    Log  \n${json}  console=yes

The response will correctly list the params you've encoded:

{
    "args": {
        "filter": "2Bedrooms",
        "type": "Condos"
    },
    "headers": {
        "accept": "*/*",
        "accept-encoding": "gzip, deflate",
        "authorization": "Basic TWFyazpTdXBlclNlY3JldA==",
        "host": "postman-echo.com",
        "user-agent": "python-requests/2.25.0",
        "x-amzn-trace-id": "Root=1-5fb43ae9-1880b0a621c864b06ce1f54a",
        "x-forwarded-port": "80",
        "x-forwarded-proto": "http"
    },
    "url": "http://postman-echo.com/get?type=Condos&filter=2Bedrooms"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.