Hi
The below code with Rest-assured i am not getting a JSON response.
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.response.Response;
String logInPayload = "{}" // take any JSON request string.
RestAssured.baseURI = "https:"; // take any https post utl.
JSONObject jsonObject = (JSONObject) jsonParser.parse(logInPayload);
Response resp = RestAssured.given()
.accept(ContentType.JSON).and()
.header("Accept", "application/json").and()
.header("Content-Type", "application/json").and()
.body(jsonObject.toJSONString()).and()
.request().relaxedHTTPSValidation().and()
.when().post(RestAssured.baseURI);
System.out.println(resp.getBody().asString());
System.out.println(resp.contentType());
Out Put as:
<html>
<head><title>401 Authorization Required</title></head>
<body bgcolor="white">
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.4.7</center>
</body>
</html>
text/html
instead of above text/html i am expecting as json string.
Thanks in advance
Original issue reported on code.google.com by ssireku...@gmail.com on 6 Mar 2015 at 6:48
Original issue reported on code.google.com by
ssireku...@gmail.com
on 6 Mar 2015 at 6:48