2016-11-14 73 views
0

我正在使用multipart來自動化web服務。如何使用restassured設置contentdisposition標頭

隨着請求正文我通過以下: 響應response2 = given()。 config(RestAssured.config()。sslConfig(new SSLConfig()。relaxedHTTPSValidation()))。

multiPart("test1", new File(System.getProperty("user.dir")+"\\src\\ExcelFiles\\test1.pdf")). 
    header("SM_USER","BR86609").header("applicationId","163500"). 
    contentType("multipart/mixed"). 
    body("{\"productName\": \"WS_prodCreated_wsAuto\",\"productType\":\"SN\",\"issuerProvider\":\"BANKO BANCOMER\",\"issueDate\":1421756467944,「tipSheetCount」:2" 
       + "\"tipSheets\": [{\"fileName\":\"test.xlsx\",\"comments\":\"Comments 1\",\"version\":\"DRAFT\"},{\"fileName\":\"test1.pdf\",\"comments\":\"Comments 1\",\"version\":\"FINAL\"}]," 
           + "\"distributionList\":[\"[email protected]\",\"[email protected]\"],\"genericProduct\": false,\"productScope\": [\"India\",\"US\"]}"). 

    when(). 
    post("https://vm-5aeb-7dd1.nam.nsroot.net:18121/IPRRatingWebServiceClone3/rest/create/product"). 
    then(). 
    extract().response(); 

運行此請求後,我獲得以下性反應: 說明頁面文件test1.pdf不發送尺寸參數作爲contentdisposition頭

所以這裏的問題是一部分..如何通過「 contentdisposition頭「與req。身體使用restassured。

我的意圖是將文件大小與請求一起傳遞。

回答

0

嘗試添加內容,配置如下

.header("Content-Disposition", "attachment; filename=test1.pdf") 
+0

謝謝你的回覆。我會試試這個..現在將盡快分享結果 –

+0

沒有爲我工作..它顯示相同的響應 - Tipsheet文件test1.pdf不發送作爲contentdisposition標頭的一部分的大小參數 –

+0

嘗試從POSTMAN /手動RESTClient,看看你是否得到適當的響應 – Ramu