Object repo using global variable passed but test case failed. Unable to send request (Root cause: java.net.MalformedURLException

i am using global variable for hostname and port at object repo. test and verify passed.
http://${KafkaRestHostName}:${KafkaRestPort}/consumers/NewDrugConsumerGroup

but when run at test suite, console shown error:

2019-10-16 11:24:11.530 DEBUG t.1a-Subscribe and Consume NewDrug Topic - 5: sendRequest(findTestObject(“Kafka/1b-Subscribe NewDrug Topic”, [“topic_name”:topic]))
2019-10-16 11:24:11.646 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to send request (Root cause: java.net.MalformedURLException: For input string: “${KafkaRestPort}”
at com.kms.katalon.core.webservice.common.RestfulClient.sendRequest(RestfulClient.java:74)
at com.kms.katalon.core.webservice.common.RestfulClient.send(RestfulClient.java:59)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.doCall(SendRequestKeyword.groovy:42)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.call(SendRequestKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.sendRequest(SendRequestKeyword.groovy:38)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.execute(SendRequestKeyword.groovy:33)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.sendRequest(WSBuiltInKeywords.groovy:40)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$sendRequest$0.call(Unknown Source)
at 1a-Subscribe and Consume NewDrug Topic.setupConsumer(1a-Subscribe and Consume NewDrug Topic:36)
at Script1571031536270$setupConsumer.callCurrent(Unknown Source)
at 1a-Subscribe and Consume NewDrug Topic.run(1a-Subscribe and Consume NewDrug Topic:23)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:169)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:142)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:91)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1571196244505.run(TempTestSuite1571196244505.groovy:35)
Caused by: java.lang.NumberFormatException: For input string: “${KafkaRestPort}”
at com.kms.katalon.core.webservice.common.RestfulClient.sendRequest(RestfulClient.java:74)
at com.kms.katalon.core.webservice.common.RestfulClient.send(RestfulClient.java:59)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.doCall(SendRequestKeyword.groovy:42)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.call(SendRequestKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.sendRequest(SendRequestKeyword.groovy:38)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.execute(SendRequestKeyword.groovy:33)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.sendRequest(WSBuiltInKeywords.groovy:40)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$sendRequest$0.call(Unknown Source)
at Script1571031536270.setupConsumer(Script1571031536270.groovy:36)
at Script1571031536270$setupConsumer.callCurrent(Unknown Source)
at Script1571031536270.run(Script1571031536270.groovy:23)
… 13 more
)

provided those variables are defined in the profile, you should use them like this:

http://${GlobalVariable.KafkaRestHostName}:${GlobalVariable.KafkaRestPort}/consumers/NewDrugConsumerGroup

the form you have used it is for variables declared at test object level (which in turn can also receive the value from globals directly or binded in the testcase)

same error
i managed to have workaround, using the same HTTP
but adding global variable in test case when calling the object, something like this
WS.sendRequest(findTestObject(‘Kafka/0a-Delete NewDrug Consumer’, [(‘KafkaRestHostName’) : GlobalVariable.KafkaRestHostName, , (‘KafkaRestPort’) : GlobalVariable.KafkaRestPort]))

2019-10-16 13:23:22.268 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to send request (Root cause: java.net.MalformedURLException: For input string: “${KafkaRestPort}”
at com.kms.katalon.core.webservice.common.RestfulClient.sendRequest(RestfulClient.java:74)
at com.kms.katalon.core.webservice.common.RestfulClient.send(RestfulClient.java:59)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.doCall(SendRequestKeyword.groovy:42)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.call(SendRequestKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.sendRequest(SendRequestKeyword.groovy:38)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.execute(SendRequestKeyword.groovy:33)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.sendRequest(WSBuiltInKeywords.groovy:40)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$sendRequest$0.call(Unknown Source)
at 1c-Subscribe and Consume UpdatedDrug Topic.setupConsumer(1c-Subscribe and Consume UpdatedDrug Topic:40)
at Script1571031536292$setupConsumer.callCurrent(Unknown Source)
at 1c-Subscribe and Consume UpdatedDrug Topic.run(1c-Subscribe and Consume UpdatedDrug Topic:24)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:169)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:142)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:91)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1571203386221.run(TempTestSuite1571203386221.groovy:35)
Caused by: java.lang.NumberFormatException: For input string: “${KafkaRestPort}”
at com.kms.katalon.core.webservice.common.RestfulClient.sendRequest(RestfulClient.java:74)
at com.kms.katalon.core.webservice.common.RestfulClient.send(RestfulClient.java:59)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.doCall(SendRequestKeyword.groovy:42)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.call(SendRequestKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.sendRequest(SendRequestKeyword.groovy:38)
at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.execute(SendRequestKeyword.groovy:33)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.sendRequest(WSBuiltInKeywords.groovy:40)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$sendRequest$0.call(Unknown Source)
at Script1571031536292.setupConsumer(Script1571031536292.groovy:40)
at Script1571031536292$setupConsumer.callCurrent(Unknown Source)
at Script1571031536292.run(Script1571031536292.groovy:24)
… 13 more
)

works for me on version 6.3.3.
so check if you are using the right profile and you provided right values.

hmm not sure about your case.
for our case, the hostname and port is crucial when connecting to other system.
i will use my workaround method, since modify object repo is quite tedious as i already completed near to 30 cases.

@Gan_Jyi_Yng i was using a public api for the demo, but the ideea is, any proper used variable is substituted in the url. so, my guess is you are doing something wrong (or incomplete)

It could be bug in katalon when both host and port required by api???

nope!
see bellow, why for me is working?

{
  "log" : {
    "version" : "1.2",
    "pages" : [ ],
    "entries" : [ {
      "startedDateTime" : "2019-10-16T10:55:54.431Z",
      "request" : {
        "method" : "GET",
        "url" : "https://reqres.in:443/api/users?page=2",
        "httpVersion" : "",
        "cookies" : [ ],
        "headers" : [ {
          "name" : "Accept",
          "value" : "application/json"
        }, {
          "name" : "Content-Type",
          "value" : "application/json"
        } ],
        "queryString" : [ {
          "name" : "page",
          "value" : "2"
        } ],
        "headersSize" : 0,
        "bodySize" : 0,
        "comment" : ""
      },
      "response" : {
        "status" : 200,
        "statusText" : "",
        "httpVersion" : "",
        "cookies" : [ ],
        "headers" : [ {
          "name" : null,
          "value" : "HTTP/1.1 200 OK"
        }, {
          "name" : "CF-RAY",
          "value" : "526980cf2e11d0fd-TXL"
        }, {
          "name" : "Server",
          "value" : "cloudflare"
        }, {
          "name" : "Access-Control-Allow-Origin",
          "value" : "*"
        }, {
          "name" : "Connection",
          "value" : "keep-alive"
        }, {
          "name" : "Date",
          "value" : "Wed, 16 Oct 2019 10:55:54 GMT"
        }, {
          "name" : "Via",
          "value" : "1.1 vegur"
        }, {
          "name" : "Accept-Ranges",
          "value" : "bytes"
        }, {
          "name" : "CF-Cache-Status",
          "value" : "HIT"
        }, {
          "name" : "Cache-Control",
          "value" : "public, max-age=14400"
        }, {
          "name" : "Etag",
          "value" : "W/\"414-k36Lu9tCb0XMJeh2/UG19C4xbw4\""
        }, {
          "name" : "Set-Cookie",
          "value" : "__cfduid=d8a05df924c8156d98992d33d066bd8d01571223354; expires=Thu, 15-Oct-20 10:55:54 GMT; path=/; domain=.reqres.in; HttpOnly; Secure"
        }, {
          "name" : "Expires",
          "value" : "Wed, 16 Oct 2019 14:55:54 GMT"
        }, {
          "name" : "Content-Length",
          "value" : "1044"
        }, {
          "name" : "Age",
          "value" : "1467"
        }, {
          "name" : "Expect-CT",
          "value" : "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
        }, {
          "name" : "X-Powered-By",
          "value" : "Express"
        }, {
          "name" : "Content-Type",
          "value" : "application/json; charset=utf-8"
        } ],
        "content" : {
          "size" : 1044,
          "mimeType" : "application/json; charset=utf-8",
          "text" : "{\"page\":2,\"per_page\":6,\"total\":12,\"total_pages\":2,\"data\":[{\"id\":7,\"email\":\"michael.lawson@reqres.in\",\"first_name\":\"Michael\",\"last_name\":\"Lawson\",\"avatar\":\"https://s3.amazonaws.com/uifaces/faces/twitter/follettkyle/128.jpg\"},{\"id\":8,\"email\":\"lindsay.ferguson@reqres.in\",\"first_name\":\"Lindsay\",\"last_name\":\"Ferguson\",\"avatar\":\"https://s3.amazonaws.com/uifaces/faces/twitter/araa3185/128.jpg\"},{\"id\":9,\"email\":\"tobias.funke@reqres.in\",\"first_name\":\"Tobias\",\"last_name\":\"Funke\",\"avatar\":\"https://s3.amazonaws.com/uifaces/faces/twitter/vivekprvr/128.jpg\"},{\"id\":10,\"email\":\"byron.fields@reqres.in\",\"first_name\":\"Byron\",\"last_name\":\"Fields\",\"avatar\":\"https://s3.amazonaws.com/uifaces/faces/twitter/russoedu/128.jpg\"},{\"id\":11,\"email\":\"george.edwards@reqres.in\",\"first_name\":\"George\",\"last_name\":\"Edwards\",\"avatar\":\"https://s3.amazonaws.com/uifaces/faces/twitter/mrmoiree/128.jpg\"},{\"id\":12,\"email\":\"rachel.howell@reqres.in\",\"first_name\":\"Rachel\",\"last_name\":\"Howell\",\"avatar\":\"https://s3.amazonaws.com/uifaces/faces/twitter/hebertialmeida/128.jpg\"}]}",
          "comment" : ""
        },
        "redirectURL" : "",
        "headersSize" : 607,
        "bodySize" : 1044,
        "comment" : ""
      },
      "cache" : { },
      "timings" : {
        "comment" : "",
        "blocked" : -1,
        "connect" : 325,
        "send" : 0,
        "wait" : 0,
        "dns" : -1,
        "receive" : 0,
        "ssl" : -1
      },
      "comment" : "",
      "_katalonRequestInformation" : {
        "name" : "4",
        "testObjectId" : "C:\\Users\\username\\Katalon Studio\\Test\\Object Repository\\Request global vars 4.rs",
        "harId" : "d6486adf-53eb-4828-a394-7aeefd2aab36",
        "reportFolder" : null
      },
      "time" : 325
    } ],
    "comment" : ""
  }
}

works also from a testcase or a testsuite:

I can see differences.

  1. You have additional variable for https
  2. Your case is get, not post.

not valid arguments.

    1. in the very first pic i use no port, no protocol, just passing the full base url with the protocol and no port. since is https, 443 is implied, in your case (for http) may be 80 or any other custom (check with your dev team), as i did it in the second example
    1. it doesn’t matter. i won’t spend my time anymore to show you that it will work with POST also (and even body parametrizing), i have work to do.
      feel free to debug your code.
      IMHO, there is no bug here, only lack of understanding how the API you are trying to test is working.

Not to argue, just to pointing out when you try to prove that yours is working. But not looking at the error why is throwing just java exceptional at port only.

as i said. check your code and make sure you are passing the right values to your request object.
there is nothing wrong with katalon. just use it properly

you have posted only some errors, and no code sample, nada, niente.
we have no clue what your setup is.
how should we know what you are doing wrong?

1 Like