Home > Software design >  How to fetch the http status code when the response type defined is string instead of Respone
How to fetch the http status code when the response type defined is string instead of Respone

Time:09-30

int statusCode = res.getStatusLine().getStatusCode();Please refer for code

Is there any way to cast string to Response to use the predefined method getStatusCode() else any other way to fetch the status code?

CodePudding user response:

You can have both Response and String, for example.

Response response = given().patch();
int statusCode = response.statusCode();

String res = response.asString();
  • Related