小编kri*_*ish的帖子

如何通过HttpClient在POST请求中将JSON数据作为主体发送

我有一个要求.我有一个有效的POST电话("http://localhost:8080/POSTAPI/table/testmaster/create").我JSON通过邮递员发送数据,并将详细信息插入到MySQL数据库中.现在我正在尝试发送json数据apache httpcleint.但是,它无法插入mysql数据库.

CloseableHttpClient client = HttpClients.createDefault();
HttpPost post = new HttpPost("http://localhost:8080/POSTAPI/table/testmaster/create");
    JSONObject testmaster = new JSONObject();
    testmaster.put("testRunId", testRunId);
    testmaster.put("testClassName", className);
    testmaster.put("testMethod", methodName);
    testmaster.put("createdBy", "leela");
    testmaster.put("createdDate", startDate);
    testmaster.put("lastUpdatedBy", "raghu");
    testmaster.put("lastUpdatedDate", endDate);
    testmaster.put("attribute1", "methodName");
    testmaster.put("attribute1Value",methodName );
    testmaster.put("attribute2", "result");
    testmaster.put("attribute2Value", successResult);
    testmaster.put("attribute3", "Test Suite");
    testmaster.put("attribute3Value", suiteName);
    testmaster.put("attribute4", "test group");
    testmaster.put("attribute4Value", TestGroup);
    testmaster.put("attribute5", "dataprovider");
    testmaster.put("attribute5Value", dataProvider);

    StringEntity stringEntity = new StringEntity(testmaster.toString());
    post.setEntity(stringEntity);
    post.setHeader("Accept", "application/json");
    post.setHeader("Content-type", "application/json");
    CloseableHttpResponse response = client.execute(post);
    System.out.println("Status: "+response.getStatusLine());
Run Code Online (Sandbox Code Playgroud)

这是我试过的.如果有人想通过httpclient或任何其他替代方案进行后期操作,请告诉我.提前致谢.

mysql rest json apache-httpclient-4.x

5
推荐指数
1
解决办法
789
查看次数

无法通过詹金斯连接到 AWS 从站

我正在尝试使用 jenkins 中的 EC2 插件配置主从配置。配置 EC2 插件后,jenkins 成功启动了从站,我什至可以 ssh 进入该从站。但是当我查看 jenkins 中的 Node 日志时,我发现 jenkins 无法连接到 slave。这是我所看到的:

This node is offline because Jenkins failed to launch the slave agent   on it. See log for more details
INFO: Authenticating as ubuntu
Jan 31, 2017 6:29:00 PM null
INFO: Connecting to ip-10-226-254-52.ec2.internal on port 22, with timeout 10000.
Jan 31, 2017 6:29:10 PM null
INFO: Failed to connect via ssh: The kexTimeout (10000 ms) expired.
Jan 31, 2017 6:29:10 PM null
INFO: …
Run Code Online (Sandbox Code Playgroud)

ssh continuous-integration amazon-ec2 jenkins jenkins-plugins

2
推荐指数
1
解决办法
4172
查看次数