Is there a way to capture, view or log a Restful API call made from Katalon


#1

I want to be able to see the Rest POST call I am making from Katalon (header and body -in json) so I can easily troubleshoot my Restful APi calls. I have found nothing in the logs… Where is the request logged? if not logged, what can I do to capture the request as sent?


#2

Hi there,

We understand your concern. However, those kinds of logs are not supported in current release yet. We’ve planned to do this in later releases.

Thanks


#3

I see I can get the response. I want the POST request, AS SENT.
When I use a product like Soap UI, I can see the raw request:

POST https://auth-env2.myserver.net/api/auth/oauth2/token HTTP/1.1
Accept-Encoding: gzip,deflate
Authorization: Basic realm=myserver.NET&grant_type=password&username=logon&password=password&timestamp=1487626351&nonce=b1j670
InstitutionId: 123456789
Content-Type: application/json
Content-Length: 0
Host: auth-env2.myserver.net
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

is there a way to log this?


#4

Hi there,

In your case, you can use ‘getResponseBodyContent’ function after you sending a request. This way you can display responsed content after sending a request.

Example

‘Send a SOAP request and returns its response’
def response = WS.sendRequest(findTestObject(‘SOAP_ConvertWeight’))

println response.getResponseBodyContent()

Output example:

3000


#5

Hello!

I have the same problem.

When your have resolution? In what version?

Thanks.


#6

I would like to see my requests that are sent out also, is this implemented yet? or is it coming soon?


#7

+1


#8

I have the same issue.

Is it possible to print request in the script mode?

For response, I use println(response.getResponseText()) to get the response text logged when running the test case.
However, I could not sort it out how to print the outgoing request.

Anyone, any idea?


#9

I also have the same problem


#11

I am using something like this:

request = findTestObject('blahBlahYourRequestObjectHere')
    
'When'
WS.comment("Sending POST request: ${request.getRestUrl()}")
WS.comment("With body: ${request.getHttpBody()}")
response = WS.sendRequest(request)

to display the request info into the log (will be recorded also in the html report)
if you set the log level to TRACE, will be shown also into the console log (or use println instead)


#12

request = findTestObject (‘create transaction/shareFolder - Copy’)

println (WS. comment ( request.getRestUrl()))

println(WS. comment ( request.getHttpBody()))

not working for me . it is the correct for me


#13

Thank you everyone for the feedback. Since 5.9.1 all API calls are saved as HAR files. Their locations are written in the logs.


#14

use either println, or WS.coment, not both combined in the same line

WS.comment(request.getRestUrl())
OR
println( request.getRestUrl())


#15

@devalex88 can you please explain how to find those files? I can’t find any .har files after GET requests. I’m using:

image


#16

In 5.10.0 this function has to be enabled manually

We have plan to enable it by default in next versions.


#17

So the HAR files are generated only a test case runs? Is it possible in any way to see request’s header when I just click this button?


#18

Unfortunately it is not available at this moment, but you will have it in next versions.

As a workaround, please take a look at Fiddler.


#19

Thanks! I’ve installed it and got all the info.


#20

Try this. !!!

‘For logging request’
System.out.println(request.getHttpBody())

‘For logging response’
System.out.println(response.response.getResponseBodyContent())


#21

@ devalex88
still there are issues, we are not able to see the response in logs