簡體   English   中英

Rest 保證問題 io.restassured.internal.RestAssuredResponseImpl@46fc522d 響應

[英]Rest assured issue io.restassured.internal.RestAssuredResponseImpl@46fc522d in response

在執行時,我收到 io.restassured.internal.RestAssuredResponseImpl@46fc522d,請查看代碼並查看隨附的 postman 請求參數。 請注意,它的內容類型是 multipart/form-data

public  static Response uploadDocument(String url, String documentType, String firstName, String lastName, String nationality, String dateExpiry, String dateIssue, String dob, String fullName, String gender, String identityNo, String middleName, String files, String files2, String token, String cookie, String xsrfToken) {
    Response response = given()
                .header("Content-Type", "multipart/form-data")
            .config(config().multiPartConfig(multiPartConfig().defaultSubtype("mixed")))
            .header("cookie", cookie)
            .header("X-XSRF-TOKEN", xsrfToken)
    .formParam("documentType", documentType).
                    formParam("firstName", firstName).
                    formParam("lastName", lastName).
                    formParam("nationality", nationality).
                    formParam("dateExpiry", dateExpiry).
                    formParam("dateIssue", dateIssue).
                    formParam("dob", dob).
                    formParam("fullName", fullName).
                    formParam("middleName", middleName).
                    formParam("gender", gender).
                    formParam("identityNo", identityNo).
    multiPart("files",  new File(files),"application/png" ).
    multiPart("files", new File(files2),"application/png" ).
    auth().oauth2(token)
                .when().get(url)
                    .then().extract().response();
    return response;
}

Postmain 請求表單數據

我相信這已經在評論中得到了回答,但是將其移至答案部分,以便可以接受答案。 有兩種方法可以將響應 object 轉換為用於記錄或打印的字符串:

String print() :打印響應正文並將其作為字符串返回。 主要用於編寫測試時的調試目的。 返回: 作為字符串的正文。

String prettyPrint() :如果可能的話,漂亮地打印響應正文並將其作為字符串返回。 主要用於編寫測試時的調試目的。 內容類型 JSON、XML 和 HTML 可以進行漂亮的打印。 返回: 作為字符串的正文。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM