如何将UiPath与HttpsURLConnection连接?

时间:2019-05-27 05:18:30

标签: java authentication httpsurlconnection uipath

我试图用HttpsURLConnection调用Java中的UiPath,但是我一直都拒绝连接。

...
URL url = "https://platform.uipath.com/api/account/authenticate";
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
OutputStream os = con.getOutputStream(); // Exception Connection refused
...

我以为这不是连接时的身份验证,我发现了PasswordAuthentication,但这仅适用于id / pw。

URL url = "https://platform.uipath.com/api/account/authenticate";
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
Authenticator.setDefault(new Authenticator() {
    @Override
    protected PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication("admin", "postman123".toCharArray());
    }
  });
con.connect();
...

UiPath身份验证具有三个这样的参数,如何连接UiPath进行身份验证?

{
    "tenancyName": "postman",
    "usernameOrEmailAddress": "admin",
    "password": "postman123"
}

0 个答案:

没有答案