[基于以下JSON使用Rest Assured传递POST请求的JSON数组

问题描述 投票:0回答:2

我对“放心的人”是陌生的,请有人可以帮助我根据以下输出创建正文请求:

{
    "CustomerID": "539177",
    "ReminderTitle": "Demo Reminder Tds",
    "ReminderDescription": "xyz Reminder",
    "ReminderLocation": "New Delhi",
    "ReminderDate": "2020-03-27",
    "ReminderTime": "15:33",
    "attendees": [{
        "CustomerContactID": "122"
    }]
}

示例:

Map <String, String> body = new HashMap <String, String> ();

body.put("CustomerID", CustomerID);
body.put("ReminderTitle", "Demo Reminder Tds");
body.put("ReminderDescription", "xyz Reminder");
body.put("ReminderLocation", "New Delhi");
body.put("ReminderDate", "2020-03-27");
body.put("ReminderTime", "15:33");
rest-assured
2个回答
0
投票
Map<String, Object> map = new LinkedHashMap<>();
map.put("CustomerID", "539177");
map.put("ReminderTitle", "Demo Reminder Tds");
map.put("ReminderDescription", "xyz Reminder");
map.put("ReminderLocation", "New Delhi");
map.put("ReminderDate", "2020-03-27");
map.put("ReminderTime", "15:33");
map.put("attendees", Arrays.asList(new LinkedHashMap<String, Object>() {
    {
        put("CustomerContactID", "122");
    }
}));

0
投票

Rest Assured接受.body(String body)方法中的String对象。但仅适用于POST和PUT方法。检查documentation

© www.soinside.com 2019 - 2024. All rights reserved.