java—在postman中获得200个代码,但在通过rest assured自动化相同请求的同时获得400个代码

5t7ly7z5  于 2021-07-12  发布在  Java
关注(0)|答案(0)|浏览(299)

在此处输入图像描述
在此处输入图像描述
在postman中,我能够获得200个状态代码,但是当我尝试使用rest-assured自动化它时,我得到了400个错误。

public class trial {
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        RestAssured.baseURI="https://api.planet.com";
        Response res=given().
        header("Authorization", "api-key ab2118c30721496495ddc8d4f3603d69").
        header("Content-Type", "application/json").
        queryParam("strict", "false").
        body("{" + 
                "  \"filter\": {  " + 
                "   \"type\":\"AndFilter\"," + 
                "   \"config\": [" + 
                "       {  " + 
                "         \"type\":\"RangeFilter\"," + 
                "         \"field_name\":\"cloud_cover\"," + 
                "         \"config\":{ " + 
                "            \"lte\":0.5" + 
                "         }" + 
                "       }" + 
                "  ]" + 
                "   " + 
                "}," + 
                "  \"item_types\": [\"PSScene3Band\"]," + 
                "  \"name\": \"Assignment\"" + 
                "}").
                when().
                post("/data/v1/searches/").
                then().assertThat().statusCode(200).and().contentType(ContentType.JSON).
                extract().response();

        JsonPath js=ReusableMethods.rawToJson(res);
        System.out.println(res.getBody().asString());

    }

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题