Rest-API login issues

HI, I’m getting io error when I try to login via rest api, please help me out.

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<http method="post" url ="http://localhost/workfusion/api/dologin/">
	<http-param name="j_username">workfusion</http-param>
	<http-param name="j_password">workfusion</http-param>
</http>
    <export include-original-data="true"></export>

</config>

I’m getting below error :

10:52:48 [INFO] HttpProcessor starts processing…
10:52:48 [INFO] HttpParamProcessor starts processing…
10:52:48 [INFO] ConstantProcessor starts processing…
10:52:48 [INFO] ConstantProcessor processor executed in 0ms.
10:52:48 [INFO] HttpParamProcessor processor executed in 2ms.
10:52:48 [INFO] HttpParamProcessor starts processing…
10:52:48 [INFO] ConstantProcessor starts processing…
10:52:48 [INFO] ConstantProcessor processor executed in 0ms.
10:52:48 [INFO] HttpParamProcessor processor executed in 0ms.
10:54:18 [ERROR] IO error during HTTP execution for URL: http://localhost/workfusion/api/dologin/
org.webharvest.exception.HttpException: IO error during HTTP execution for URL: http://localhost/workfusion/api/dologin/
at org.webharvest.runtime.web.HttpClientManager.execute(HttpClientManager.java:224)
at org.webharvest.runtime.processors.HttpProcessor.execute(HttpProcessor.java:106)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
at org.webharvest.runtime.Scraper.execute(Scraper.java:182)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:173)
at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.processTaskInputs(SingleThreadWebHarvestProcess.java:77)
at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.start(SingleThreadWebHarvestProcess.java:46)
at com.workfusion.studio.launch.WebHarvestMainLauncher.launch(WebHarvestMainLauncher.java:108)
at com.workfusion.studio.launch.WebHarvestMainLauncher.main(WebHarvestMainLauncher.java:180)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at org.webharvest.runtime.web.HttpClientManager.execute(HttpClientManager.java:215)
… 9 more
10:54:18 [INFO] -------------------------------------------
10:54:18 [INFO] EXECUTION FAILED
10:54:18 [INFO] Connection reset (starttask.xml:3)
10:54:18 [INFO] -------------------------------------------

hi @Lera , why the comments has been removed ??

Hi @sagar_debadwar there was a bug in Discourse that prevented people from creating new posts, so we had to roll back to the previous version, and several posts were lost.
We are very sorry for that.
Could you please post the comment again?

HI @ashapkina ,
There were 2 comments , i was expecting some help on the Login using rest-api issue , on this @Lera asked about i’m trying for SPA/RPA platform that is it .

Sorry i was unaware of the bug .

Hello @sagar_debadwar.
As I see from documentation, URL should contain secure connection https://. Could you please try and let me know whether it works?

Hello @Lera , for RPA platform it is advised to use http . And also I have tried with https as well it doesn’t worked

Hi,

I am trying to send a POST request to login to the control tower on my own domain.
According to this link, the url should be :
https://%HOSTNAME%/workfusion/api/dologin
However, I get the following response:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />

    <link rel="shortcut icon" href="/workfusion/favicon.png?v=2" type="image/png" sizes="16x16" />
    <link rel="shortcut icon" href="/workfusion/favicon-64.png?v=2" type="image/png" sizes="60x60" />
    <link rel="shortcut icon" href="/workfusion/favicon-32.png?v=2" type="image/png" sizes="32x32" />

    <title>Control Tower</title></head>
<body>
    <div id="app" data-error-404="true"></div>
        <!--Do not remove this, required by https://github.com/tomchentw/react-prism -->
        <script type="text/javascript" src="/workfusion/resources/js/prism.js"></script>
        <!--Comment first row and uncomment second for hot-loading in dev mode -->
        <script type="text/javascript" src="/workfusion/components/bundle.js?ver=ce1b7c24"></script>
        <!--<script type="text/javascript" src="http://localhost:3333/bundle.js"></script>-->
</body>
</html>

Could you please help me to find the correct url to execute my POST request?
Thank you very much

1 Like

Hi @sagar_debadwar.
Are you sure regarding your credentials? Are they correct - workfusion/workfusion? As I understand, you should use your real Control tower credentials. And also seems that URL is incorrect. I checked on my side and it works for me as below:

<http method="post" url ="http://localhost:15280/workfusion/api/dologin">
	<http-param name="j_username">username</http-param>
	<http-param name="j_password">password</http-param>
</http>

Dear @alasbleis,

Can you please show me your Control Tower link, if possible?

The hostname is confidential however the link I used for the login is as followed:
https://hostname/workfusion/api/v2/workfusion/service/info

Thank you. Some clarifications about your link. Which format is used for it? Like “hostname:port” or just “hostname”?
You can look at my previous post in this thread with the example of working POST method:

I have both link, one using hostname:port and another with hostname alone, however they both returns the error above.
I don’t think the problem is code related (for info, I’m using this code sample) since I can’t even get a success connection using postman (I keep having the error mentionned previously)

Note, I tried the code you provided above and had the same error

hello @Lera , After adding port to url it’s working fine , however i’m getting error for below url .

url :

error :

<!doctype html>HTTP Status 401 – Unauthorizedh1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}

HTTP Status 401 – Unauthorized


Type Status Report

Message Full authentication is required to access this resource

Description The request has not been applied because it lacks valid authentication credentials for the target resource.


Apache Tomcat/8.5.23

hello @Lera,@alasbleis ,

even i’m getting the same response , is anything went wrong ??

I think you get a different error specifying to your ids to connect (either username or password) are incorrect hence the authentification problem

HI @alasbleis , Username and password is correct only i’m able to login to control tower with the same credentials .

I checked on my side, but didn’t get any error with this code:

<http method="post" url ="http://localhost:15280/workfusion/api/v2/workfusion/task/5ed1b4a2-671c-4eef-b99a-29c376b04c81/start">
    	<http-param name="j_username">username</http-param>
    	<http-param name="j_password">password</http-param>
    </http>

Console results of the execution of this script:

Please check whether your Control Tower is up and running. And also please advise how you got task uuid. Because in my case, I copied from the URL business process instance.

hi @Lera ,

i’m also getting the same output in code perpspective but workflow is not getting executed since http response is 404 (unauthorised) .

<!doctype html> HTTP Status 401 – Unauthorized h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}

HTTP Status 401 – Unauthorized

Type Status Report

Message Full authentication is required to access this resource

Description The request has not been applied because it lacks valid authentication credentials for the target resource.

Oh I think I see the problem now:
You are trying to start a BP within being logged in, that’s why you get an authentification error.
You should first do a POST request to log in and then do a POST request to start the BP.
See this link

HI @alasbleis ,
In case of basic authentication we will not get any session id . is the case different with Work fusion authentication mechanism .

1 Like