放心呼叫时出现400错误,但在邮递员中进行时我得到200

时间:2019-05-09 21:08:22

标签: java api postman rest-assured web-api-testing

enter image description here enter image description here我在邮递员中手动获得200状态代码,但是在自动化过程中却出现400错误。错误在哪里?

@Test
    public void getTokenBeforeTest() {      
        Response resp = RestAssured.with().auth().preemptive().basic("asddannodsfdsnims", "password")
                .contentType("multipart/form-data").and().header("grant_type", "client_credentials").and()
                .header("Authorization", "Basic ZGFubm9uaW1zOnBhc3N3b3Jk")
                .post("http://test.api......com/uaa/oauth/token");
        int code = resp.getStatusCode();
        String response = resp.asString();
        System.out.println(code);
        System.out.println(response);
        Assert.assertEquals(code, "200");

0 个答案:

没有答案
相关问题