You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose we have response json like below, we want to get complete json to deserialize into dictionary(collection) inorder to verify from database but .Retrieve(x=> x) is crashing.
I have the same problem, I need the response body to perform validations with the database.
I'm working on a big project and this is essential for validations.
The lack of strongly typed Retrieve can be gotten around with something like JSON.net to serialize/deserialize to your desired type. I use an extension method like the following to wrap this functionality:
varresponse=newRestAssured().Given().Name("JsonIP Test Suite").Header("Content-Type","application/json").Header("Accept-Encoding","gzip,deflate").When().Get("http://jsonip.com").Then().RetrieveBody<Dictionary<string,string>>();Assert.Equal(response["ip"],"2605:6000:f705:ab00:78e3:1959:78d4:bd76");
where Dictionary<string, string> is whatever type you want to convert the response to.
Suppose we have response json like below, we want to get complete json to deserialize into dictionary(collection) inorder to verify from database but .Retrieve(x=> x) is crashing.
{
"customerId": "12345",
"title": "GitHub",
"Address": {
"City": "NYC",
"Zip": "11223344"
},
"alias": {
"type": "ContactNumber",
"value": "12345678910"
},
"Membership": "Individual"
}
The text was updated successfully, but these errors were encountered: