Unable to connect Appium with UFT due to 401 error?

Hi I am trying to establish connection with my appium with UFT , i am running into 401 issue(connection refused), Please advise! the below code is from my framework- DriverManager file and CapabilitiesManager                                    

AndroidDriver<RemoteWebElement> driver = null;

String cloudUrl=props.getHpmcProperty("hpmcURL");

if (driver == null) {

try {

utils.log().info("Initializing driver");

switch (platformName) {

case "Android":

System.out.println("UFTM session was successfully trying to connect [Android Device]");

driver = new AndroidDriver<>(new URL(cloudUrl+"/wd/hub"), dc.getCaps());

System.out.println("UFTM session was successfully created [Android Device]");

break;

case "browser":

webdriver = new RemoteWebDriver(new URL(cloudUrl), (Capabilities) dc.getWebCaps());

}

public DesiredCapabilities getCaps() throws Exception {

PropertyManager props = PropertyManager.getInstance();

try {

utils.log().info("getting android capabilities");

String deviceName = props.getDeviceProperty("deviceName");

String platformName = props.getDeviceProperty("platformName");

String platformVersion = props.getDeviceProperty("platformVersion");

String udid = props.getDeviceProperty("udid");

String mcUserId = props.getHpmcProperty("Username");

String mcPwd = props.getHpmcProperty("Password");

String oauthClientId = props.getHpmcProperty("oauthClientId");

String oauthClientSecret = props.getHpmcProperty("oauthClientSecret");

String tenantId = props.getHpmcProperty("tenantId");

// String appPath = props.getDeviceProperty("appPath");

DesiredCapabilities caps = new DesiredCapabilities();

caps.setCapability(MobileCapabilityType.PLATFORM_NAME, platformName);

caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, platformVersion);

caps.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);

caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Android");

caps.setCapability(MobileCapabilityType.UDID, udid);

caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);

// UFT Mobile (HPMC) specific capabilities

caps.setCapability("uftm:serverAddress", "">https://host:port/wd/hub");

// User credentials for HPMC

caps.setCapability("Username", mcUserId);

caps.setCapability("Password", mcPwd);

caps.setCapability("uftm:oauthClientId", oauthClientId);

caps.setCapability("uftm:oauthClientSecret", oauthClientSecret);

caps.setCapability("uftm:tenantId", tenantId);

caps.setCapability("newSessionWaitTimeout", 1000);

caps.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, props.getDeviceProperty("androidAppPackage"));

caps.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, props.getDeviceProperty("androidAppActivity"));

// caps.setCapability(MobileCapabilityType.APP, appPath);

caps.setCapability(MobileCapabilityType.BROWSER_NAME, "Android");

return caps;

Error-

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote se
ssion. Please check the server log for more details. Original error: Unable to p
arse remote response: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 401 Unauthorized</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /wd/hub/session. Reason:
<pre> Unauthorized</pre></p><hr><i><small>Powered by UFT Mobile://</small></i
><hr/>

</body>
</html>

Tags: