我正在尝试使用 Rest-Assured 和 Java 为 POST API 创建测试自动化。
此 API 具有以下主体作为 Application/JSON:
{
"billing_address": {
"region": "Sao Paulo",
"region_id": 123,
"country_id": "BR",
"street": ["Av Paulista"],
"postcode": "10577",
"city": "SAO PAULO",
"telephone": "555-555-1111",
"company": "Test test",
"firstname": "Fernando",
"lastname": "Alves",
"document": "0123444064"
}
}
在我的代码中,我开发了以下方法来发送此值和请求:
public void criarPF (String srtAmbiente, String srtAPI, String srtToken, String srtRegion, String srtRegionID, String srtCountryID, String srtStreet,
String srtPostcode, String srtCity, String srtTelephone, String srtCompany, String srtFirstname, String srtLastname, String srtDocument) {
String uriBase = srtAmbiente;
String Api = srtAPI;
Map<String, String> addressContent = new HashMap<String,String>();
addressContent.put("region", srtRegion);
addressContent.put("region_id", srtRegionID);
addressContent.put("country_id", srtCountryID);
addressContent.put("street", srtStreet);
addressContent.put("postcode", srtPostcode);
addressContent.put("city", srtCity);
addressContent.put("telephone", srtTelephone);
addressContent.put("company", srtCompany);
addressContent.put("firstname", srtFirstname);
addressContent.put("lastname", srtLastname);
addressContent.put("document", srtDocument);
我收到一条错误消息,指出“street”不是一个字符串,而是一个字符串 []。
那么,如何在同一 API 主体中发送 String 和 String[] 值?
小唯快跑啊
相关分类