Rest-assured. Is it possible to extract value from request json?

前端 未结 5 921
死守一世寂寞
死守一世寂寞 2020-12-24 00:36

I\'m getting response this way:

Response response = expect().statusCode(200).given().body(requestBody).contentType(\"application/json\")
.when().post(\"/admi         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 01:31

    I found the answer :)

    Use JsonPath or XmlPath (in case you have XML) to get data from the response body.

    In my case:

    JsonPath jsonPath = new JsonPath(responseBody);
    int user_id = jsonPath.getInt("user_id");
    

提交回复
热议问题