Исключение протокола Rest Client - PullRequest
0 голосов
/ 26 января 2019

Использование JDK 1.5 для REST-клиента, но с исключением из протокола клиента.ссылался на многие вопросы переполнения стека esp введите описание ссылки здесь

, но не смог понять это.Также использовалась предварительная аутентификация, но не удалось удалить ошибку.Ниже приведен код

String host = "service now host";
    String host_url = "http://servicenow/hosturl/";
    String postData = null;


    postData = "{\"caller_id\":\"CTL SWAT\","
            + "\"short_description\":\"hello678\"," + "\"cmdb_ci\":\" CLT \","
            + "\"description\":\"Testing jdk 15\","
            + "\"contact_type\":\"Phone\","
            + "\"assignment_group\":\"NA - EWH PASE - Tier 2\","
            + "\"impact\":\"4\"," + "\"urgency\":\"4\"}" + "\",";



    CredentialsProvider credsProvider = new BasicCredentialsProvider();
    credsProvider.setCredentials(new AuthScope(new HttpHost(host)),
            new UsernamePasswordCredentials("username", "password"));

    CloseableHttpClient httpclient = HttpClients.custom()
            .setDefaultCredentialsProvider(credsProvider).build();


        HttpPost httpPost = new HttpPost(host_url);
        httpPost.setHeader("Accept", "application/json");
        httpPost.setHeader("Content-Type", "application/json");

        HttpEntity entity;
        try {
           entity = new ByteArrayEntity(postData.getBytes("utf-8"));
            httpPost.setEntity(entity);
            CloseableHttpResponse response = httpclient.execute(httpPost);


        } catch (UnsupportedEncodingException e) {
            System.out.println("Threading WORKING LEVEL 1 unsupported");
        }
         catch (ClientProtocolException e) {
             System.out.println("Threading WORKING LEVEL 1 clientprotocol"); 
        } catch (IOException e) {
            System.out.println("Threading WORKING LEVEL 1 ioexception"); 
        }
        finally{
            System.out.println("finnaly");
        }

. Используется jar-кодек 1.5, общий журнал 1.1.3, httpclient 4.3.3 и httpcore 4.3.2. Спасибо за все комментарии и помощь

...