Reputation: 305
I have a Test Case where i have to compare Rest API response with DB result. Steps i have automated are - 1. POST a request 2. Get the API response 3. Compare with DB result
After posting a request to API, when i try to evaluate it, i am getting below error -
failed: TypeError: Expression must be string, got dictionary.
create session session ${apiurl} disable_warnings=1
&{headers}= Create Dictionary Content-Type=application/json x-api-key=${api_token_key}
${api_response}= post request session ${emp_id}/${module_name} data=${request_body}
... headers=${headers}
${response_list}= evaluate ${api_response.json()}
log to console ${response_list}
Getting above error.
I am expecting below API response to be compared with the DB result.
"page": {
"size": 5,
"totalElements": 278,
"totalPages": 56,
"number": 0
},
"embedded": {
"emp": [
{
"id": 1,
"bookid": 2,
"batchid": "2018-aaa",
"title": "ash",
"sub1": 10,
"sub2": 11,
"sub failed": {
"total": {
"value": 50,
"subject": "sub6",
"filter": "[{"field":"1","exclusive":false,"operator":"IN","value":"2018-aaa"}]"
}
},
"sports": {
"total": {
"value": 12,
"subject": "PE",
"filter": "[{"field":"1","exclusive":false,"operator":"IN","value":"2018-aaa"}]"
}
},
"count": 222,
"count1": 333,
"improved": 0,
"last": "2019-08-12",
"isstudent": true
},
How to compare the above API response with DB result
Upvotes: 0
Views: 1206
Reputation: 1709
just change your param data
to json
because if you use data
it's for only Json string
type.
create session session ${apiurl} disable_warnings=1
&{headers}= Create Dictionary Content-Type=application/json x-api-key=${api_token_key}
${api_response}= post request session ${emp_id}/${module_name} json=${request_body}
... headers=${headers}
${response_list}= evaluate ${api_response.json()}
log to console ${response_list}
Upvotes: 2