嘗試在獲取請求的正文中傳遞此 JSON,請放心。創建 JSON 物件是一種方法嗎?
{
"pharmacyListId": null,
"pharmacyListName": "PTA",
"customerSetTypeId": 1,
"customerId": null,
"pharmacyId": null,
"providerAffiliateId": null,
"providerPlanId": null,
"providerChain": null,
"providerNetworkId": null,
"pharmacyZip": null,
"pharmacyZipExtension": null,
"pharmacyStateCode": "MI",
"fillDate": "2021-01-01",
"relationshipId": null,
"organizationId": null,
"paymentCentreId": null,
"providerNpi": null,
"remitReconId": null,
"countryCode": null,
"memberState": null,
"memberZipCode": null,
"memberZipCodeExtension": null
}
uj5u.com熱心網友回復:
您可以為您的 json 創建一個字串:
String Json = "{\n"
" \"pharmacyListId\": null,\n"
" \"pharmacyListName\": \"PTA\",\n"
" \"customerSetTypeId\": 1,\n"
" \"customerId\": null,\n"
" \"pharmacyId\": null,\n"
" \"providerAffiliateId\": null,\n"
" \"providerPlanId\": null,\n"
" \"providerChain\": null,\n"
" \"providerNetworkId\": null,\n"
" \"pharmacyZip\": null,\n"
" \"pharmacyZipExtension\": null,\n"
" \"pharmacyStateCode\": \"MI\",\n"
" \"fillDate\": \"2021-01-01\",\n"
" \"relationshipId\": null,\n"
" \"organizationId\": null,\n"
" \"paymentCentreId\": null,\n"
" \"providerNpi\": null,\n"
" \"remitReconId\": null,\n"
" \"countryCode\": null,\n"
" \"memberState\": null,\n"
" \"memberZipCode\": null,\n"
" \"memberZipCodeExtension\": null\n"
"}";
并且放心,您可以擁有類似的東西:
Response response = given()
.body(Json)
.when()
.get("http://restAdress")
.then()
.extract().response();
uj5u.com熱心網友回復:
首先,您需要澄清案件。盡管標準沒有明確限制通過GET請求發送有效負載,但您的 API 服務器或托管 API 代碼的 HTTP 服務器很可能會忽略該有效負載。
如果情況仍然如此,使用 RestAssured 發送 json 的最簡單方法是:
RestAssured
.with()
.proxy("localhost", proxyServer.getPort())
.body("{\n"
" \"pharmacyListId\": null,\n"
" \"pharmacyListName\": \"PTA\",\n"
" \"customerSetTypeId\": 1,\n"
" \"customerId\": null,\n"
" \"pharmacyId\": null,\n"
" \"providerAffiliateId\": null,\n"
" \"providerPlanId\": null,\n"
" \"providerChain\": null,\n"
" \"providerNetworkId\": null,\n"
" \"pharmacyZip\": null,\n"
" \"pharmacyZipExtension\": null,\n"
" \"pharmacyStateCode\": \"MI\",\n"
" \"fillDate\": \"2021-01-01\",\n"
" \"relationshipId\": null,\n"
" \"organizationId\": null,\n"
" \"paymentCentreId\": null,\n"
" \"providerNpi\": null,\n"
" \"remitReconId\": null,\n"
" \"countryCode\": null,\n"
" \"memberState\": null,\n"
" \"memberZipCode\": null,\n"
" \"memberZipCodeExtension\": null\n"
"}\n")
.contentType(ContentType.JSON)
.get("http://YOUR_ENDPOINT");
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/466450.html
上一篇:Jmeter 金牛座。如何通過屬性函式設定執行緒組屬性
下一篇:如果失敗,請多次運行Jest測驗
