1

I have a JSON body as Java String. I would like to convert this String to RestAssured Response. Is this possible?

Or

Is it possible to convert apache HttpResponse to RestAssured Response

HttpClient httpClient = HttpClientBuilder.create().build();
            HttpPost httpPost = new HttpPost(url);
            org.apache.http.entity.StringEntity entity = new org.apache.http.entity.StringEntity(body);
            httpPost.setEntity(entity);
            httpPost.setHeader("Accept", "application/json");
            httpPost.setHeader("Content-type", "application/json");
            HttpResponse httpResponse = httpClient.execute(httpPost);

I'd like to convert httpResponse to RestAssured Response

Damien-Amen
  • 7,232
  • 12
  • 46
  • 75

1 Answers1

0

The Response Javadoc says "The response of a request made by REST Assured.". So, no I don't think its possible. I would make the request with RestAssurred anyway, I find it easier.

Reference: http://static.javadoc.io/com.jayway.restassured/rest-assured/1.2.3/com/jayway/restassured/response/Response.html

Adam
  • 2,214
  • 1
  • 15
  • 26
  • Problem is I'm getting `handshake_failure` error even after upgrading my `RestAssured` version to 3.0.1 which is the latest and claims to have fixed that issue. I still see it though. That's why I'm using `HttpResponse` – Damien-Amen Sep 22 '16 at 20:52
  • @user1629109 can you update your question with the full stacktrace of that error? Or post a new question for it? Sounds like that is the problem you really want to solve. – Adam Sep 23 '16 at 20:55
  • Thanks for your response. This is exactly what I'm trying to solve https://github.com/rest-assured/rest-assured/issues/548 . RestAssured lacks SNI support. So I'm getting handshake failure error when I try to connect a server that has SNI implemented. But Apache HttpClient works like a charm – Damien-Amen Sep 24 '16 at 11:30