Java https POST请求不会返回JSON内容

Java https POST请求不会返回JSON内容,java,json,rest-assured,Java,Json,Rest Assured,下面的代码请放心(2.4.0),我没有得到JSON响应 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 c

下面的代码请放心(2.4.0),我没有得到
JSON
响应

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 url.
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());
结果是:

<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    //second println statement

提前感谢

返回流表明身份验证失败,并且您的登录有效负载字符串为空。这可能需要一个用户ID和密码,并按照服务器期望的方式进行格式化和分隔。您尝试访问的URL需要什么类型的身份验证?由于一些机密问题,我没有得到任何有效负载字符串和服务器URL。我的主要期望是,我希望获得JSON字符串作为我的输出https://You 可能有两个级别的身份验证。第一种方法就是向服务器提交一些东西。这是401计划的失败。如果您要通过此操作,那么您可能会得到预期的JSON返回,指示错误(即,没有使用给定电子邮件的用户)。@mbmast从上述代码可以完美地使用http://POST URL。对于无效用户,我得到的JSON响应为{“message”:“没有使用此电子邮件的用户”,“code”:“10003”}
{
  "message": "No such user with this email",
  "code": "10003"
}