1、get请求

ObjectMapper objectMapper = new ObjectMapper();
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder().uri(URI.create(softPhoneAddress + "/api/cfg/selectAgentBySkill?skilldbid=" + queueId))
                .GET()
                .build();
        try {
            HttpResponse<String> response =
                    client.send(request, HttpResponse.BodyHandlers.ofString());
            String body = response.body();
            List<SeatAgentsVo> seatAgentsVo = objectMapper.readValue(body, new TypeReference<List<SeatAgentsVo>>() {
            });

  2、post请求

 //objectIds转换成json字符串
        Objectids object = new Objectids();
        object.setObjectids(objectIds);
        ObjectMapper mapper = new ObjectMapper();
        String result = null;
        try {
            result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(object);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }

        HttpClient builder = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder(URI.create(softPhoneAddress + "/api/v2/stats/agents"))
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(result))
                .build();
        try {
            HttpResponse<String> send = builder.send(request, HttpResponse.BodyHandlers.ofString());
            String body = send.body();
            SeatStatus value = mapper.readValue(body, SeatStatus.class);

  

12-26 12:39