Web Service Request: Error in Katalon but Working in Postman

Hi, I’m using Katalon 6.3.2 64-bit and I’m having an issue with connection denied when run a request on my end.

Error:

Working:

java.net.SocketException: Permission denied: connect
at com.kms.katalon.core.webservice.common.RestfulClient.sendRequest(RestfulClient.java:91)
at com.kms.katalon.core.webservice.common.RestfulClient.send(RestfulClient.java:59)
at com.kms.katalon.controller.WebServiceController.sendRequest(WebServiceController.java:121)
at com.kms.katalon.composer.webservice.parts.RestServicePart$6.run(RestServicePart.java:187)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)

Same request being send using Postman and it’s working perfectly. Requesting you help on this.

Proxy Setting in Preferences:

Thank you.

Regards,
Fadzli

@kazurayam could you please help me on this? thanks

I expect your Proxy requires some authentication.

Your Postman — how is it configured with Proxy settings?

what headers do you have in postman?

@kazurayam Nope I didnt setup any proxy in Postman. Screenshot attached.

@Ibus I just send “Content-Type = application/json” only in the header.

Your Postman is referring to your “System Proxy”.

What settings do you have in the “Sytem Proxy”?


I suppose that your Katalon Studio is not setup to use your “System Proxy”. This might be a cause why your KS and Postman behave differently.

Turning off “Use System Proxy” in Postman also works for me. Hmm… the weird thing I found here is whenever I use the Katalon GUI to run the request, I’m getting connection denied but when I use script (keyword) to get the response, it works!

It happens to me also when I setup DB in Project Setting. I’m getting connection failed in GUI but it’s working fine when I use keyword to setup the connection. Not sure why this happen to me.

What do you mean by saying “Katalon GUI”? Any screenshot?

Again what do you mean by saying “GUI”? Any screenshot?

When I say Katalon GUI, it means the interface that can be used to setup the info or to send the request.

When I say script it means that I’m using groovy script. Sorry for the confusion.

Could you share the souce code of mykeyword.SampleRequestObject#buildPostApiRequest()?

package mykeyword

import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.testobject.RestRequestObjectBuilder
import com.kms.katalon.core.testobject.TestObjectProperty
import com.kms.katalon.core.testobject.impl.HttpTextBodyContent
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

public class SampleRequestObject {

	String endpoint = "http://172.16.218.228:8011/prototype/currencys/page"

	TestObjectProperty header1 = new TestObjectProperty("Content-Type", ConditionType.EQUALS, "application/json")
	TestObjectProperty header2 = new TestObjectProperty("Accept", ConditionType.EQUALS, "application/json")
	ArrayList defaultHeaders = Arrays.asList(header1, header2)

	/**
	 * POST requests
	 * @return
	 */ 
	public ResponseObject buildPostApiRequest(requestMethod, body) {
		RequestObject ro = new RestRequestObjectBuilder()
				.withRestUrl(endpoint)
				.withHttpHeaders(defaultHeaders)
				.withRestRequestMethod(requestMethod)
				.withTextBodyContent(body)
				.build()

		ResponseObject respObj = WS.sendRequest(ro)
		return respObj
	}
}

If you type http://172.16.218.228:8011/prototype/currencys/page into the address bar of your favorite, day-to-day used browser (Chrome, Firefox, IE) and send, then what do you see?

Do you see a JSON text in the browser window? or do you see “Permission denied: connect” ?

Make sure you have also “Accept = application/json” in the header. I see it is present in your keyword, that can make the difference. If still not working, inspect the generated .har file and check exactly what request has been sent when using the GUI (url and headers)

Im getting

# This page isn’t working

**172.16.218.228**  is currently unable to handle this request.

HTTP ERROR 500

I just tried sending the request again using groovy script and I can get the response properly from the server. I just cant get the same result when using Web Service Request interface. Always permission denied.

java.net.SocketException: Permission denied: connect

I already added “Accept = application/json” in the header but still getting the same error.

I cannot find HAR file for this request since I’m not able to send the request at all.

To me, your server-side application seems to have a problem. Not a problem of Katalon Studio.

Can you look at the server-side log file when this request was respended with HTTP ERROR 500?

I suppose in the server-side log file you would find some information (Java Exception Stack Trace with a message) which tells you why the server-side app failed to process the request.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.