【问题标题】:How to send multiple requests via Postman如何通过 Postman 发送多个请求
【发布时间】:2017-12-08 11:55:00
【问题描述】:

我知道我们可以通过 Postman 发送一个 json 对象作为 POST 请求。但是,我希望通过连续发送多个这样的 json 对象(数百个)。邮递员。

有什么方法可以实现吗?我被困住了,非常感谢一些解决方案。

TIA:)

【问题讨论】:

标签: json post postman


【解决方案1】:

所以我最终通过发送 json 数据。通过 POST 请求的 java 代码。 因为我只需要这个来进行负载测试,所以我不太关心这里的代码效率。可能对某人有用

String line;
JSONParser jsonParser = new JSONParser();
BufferedReader br = new BufferedReader(new FileReader("data.txt"));
while((line = br.readLine()) != null) {
            JSONObject jsonObject = (JSONObject) jsonParser.parse(line);
            HttpClient httpClient = HttpClientBuilder.create().build();
            try {
                HttpPost request = new HttpPost("http://url");
                StringEntity params = new StringEntity(jsonObject.toString());
                request.addHeader("content-type", "application/json");
                request.setEntity(params);
                HttpResponse response = httpClient.execute(request);.
            } catch (Exception ex) {
                // handle exception here
            } finally {
                httpClient.getConnectionManager().shutdown();
            }
}

【讨论】:

    猜你喜欢
    • 2017-01-22
    • 2019-10-16
    • 1970-01-01
    • 2019-09-08
    • 2021-06-24
    • 2023-03-16
    • 2019-12-20
    • 2018-09-15
    • 2018-01-08
    相关资源
    最近更新 更多