Empty items in response content

Hi everyone,

I am Bhuvi, I Started with the robot framework for automation, I found an issue the GET request should have the response of items, but it is giving me the empty item status of 200, but when tired with the Postman items, it has a value response. Kindly help me with this issue.

Thanks.

Hi Bhuvi,

I gather you are using RequestsLibrary?

From the Response Object are you looking at ${resp.text} or ${resp.json}? As those are the only ones that will show the response body, unless you want raw bytes then use ${resp.content}.

If that doesn’t solve your issue, then you’ll need to look at how your GET request is different from the one Postman is making (headers, cookies, sessions etc)

Hope that helps,

Dave.

Thanks, Dave,

I am using it with the ${Response. content} for the response body , all the headers are expected still it fail, I wonder if Is it because of using the query parameters?

Log Response Content: ${response.content}
${json_content}= Evaluate json.loads($response.content)

Regards
Bhuvi

Quite possibly, how are you passing them?

Showing the lines your robot file that aren’t working and any errors from your log is always a good idea, also screen shots of whats working in Postman is a good idea too particularly the Params and Headers tabs from Postman and the Auth tab if you are using it.

Dave.

1 Like

Hi ,

I am passingthis way
${response}= GET On Session my_session ${endpoint} headers=${headers}

${query_string}=    Set Variable    fromdate=${from_date}&todate=${to_date}
Log    Query String: ${query_string}

Thanks.

Hi Bhuvi,

A quick tip, use a code block when posting your robot script (``` on the line before and after your script)

${response}=    GET On Session     my_session     ${endpoint}     headers=${headers}
${query_string}=    Set Variable    fromdate=${from_date}&todate=${to_date}
Log    Query String: ${query_string}

Based on this the first issue is ${query_string} doesn’t exist when GET On Session so it doesn’t have any effect. Also I can’t see ${endpoint} is so I have no idea if it’s constructed correctly

Secondly the 3rd argument of GET On Session is params as the documentation mentions refer to the documentation for GET for that, it says

query string parameters can be passed as string, dictionary (or list of tuples or bytes) through the params.

so maybe your script should be like this:

${query_string}=    Set Variable    fromdate=${from_date}&todate=${to_date}
Log    Query String: ${query_string}
${response}=    GET On Session     my_session     ${endpoint}    ${query_string}     headers=${headers}

But without a clear picture of what your trying to do I can’t give you a better answer than that,

Dave.

1 Like

Thanks Dave . It worked

1 Like