使用REST-Assured进行Web服务测试:在POST请求中使用参数时收到失败响应

使用REST-Assured进行Web服务测试:在POST请求中使用参数时收到失败响应,rest,rest-assured,Rest,Rest Assured,使用带有参数的post请求时,我遇到以下错误: { "failure":{ "failureCode":"1035", "failureDetails":"Id: null format is not valid", "failureInstance":null, "failureMessage":"Malformed ID(s) detected.", "failureMessageParameter":n

使用带有参数的post请求时,我遇到以下错误:

{
    "failure":{
        "failureCode":"1035",
        "failureDetails":"Id: null format is not valid",
        "failureInstance":null,
        "failureMessage":"Malformed ID(s) detected.",
        "failureMessageParameter":null
    }
}
以下是我的代码:

LoadProperties lp = new LoadProperties();
    @BeforeTest
    public void beforeTest(){
        lp.load();
        RestAssured.keyStore(lp.getProperty("certificatePath"),lp.getProperty("certificatePassword"));
        RestAssured.trustStore(lp.getProperty("cacertsPath"), lp.getProperty("cacertsPassword"));
    }
    @Test
    public void test(){
        RestAssured.baseURI = lp.getProperty("baseURL");
        RequestSpecification request = RestAssured.given().header("Authorization", lp.getProperty("AccessToken"));
        request.header("Content-Type","application/json");
        JSONObject json  = new JSONObject();
        try{//**Here I add parameters to json object**
            json.put("", lp.getProperty(""));
            json.put("", lp.getProperty(""));
            json.put("", lp.getProperty(""));
            json.put("", lp.getProperty(""));
            json.put("", lp.getProperty(""));
            json.put("", lp.getProperty(""));
            json.put("", lp.getProperty(""));
        }catch(Exception e){
            e.printStackTrace();
        }
        request.body(json.toString());
        Response response = request.post(lp.getProperty("URL"));
        String statusCode = String.valueOf(response.statusCode());
        System.out.println(response.body().asString());
        Assert.assertEquals(statusCode, "200");
    }
但是,如果我使用硬编码数据(String sData=“{Parameters}”)传递到请求体,我会得到所需的结果,但在使用json对象时不会。我还尝试使用GSON将json对象转换为jsonString,但响应仍然与上面相同

请帮忙。
谢谢。

json.put(“,lp.getProperty(”);如果在json中添加一些键和值而不是空字符串,会发生什么情况?我在发送请求时添加键和值,并得到相同的响应。只是我不能在这里透露参数。对此表示歉意。如果没有包含实体的完整代码,调查起来有点困难,但您确定在json正文中发送了Id吗?看起来您的实体有此字段,您不发送它是的,我发送ID。您能在调试模式下运行测试并显示request.body(json.toString())中的值json.toString()?