500 server error encountered when testing the object repository

Hi,

I am new to katalon and would appreciate your help. I am creating an object repository to test an api. If it’s run with raw data, it is processed successfully.


However, when I start introducing variables in the body, 500 server error is encountered. (in_PolicyID is defined in the variable tab)

Issue is encountered if the argument has multiple branches (see line 15). For simple arguments, issue is not encountered.

Does in_PolicyID refer to a global variable in the Variables tab? You may have forgotten to set the profile. I believe, it is reset to default on every launch. Or maybe you did a typo. It is case-sensitive and all.

And you should see what the request body is like. The request getter is usually a basic snippet in the verification tab:
RequestObject request = WSResponseManager.getInstance().getCurrentRequest()

To get the body you can use:
request.getBodyContent()

Hi,

Thanks for the reply. in_PolicyID is mapped to a global variable and the value is set. The HAR file also shows that the value is passed in the request.

What does the server response say? Does it say anything?

If this is a GlobalVariable, you have to use ${GlobalVariable.variable_name}.
the form ${variable_name} is to be used when the variable is defined in the test object ‘Variables’ tab.

Not sure how the har file shows that was properly resolved, please re-check.

Hi,
The response body is empty, just the 500 internal server error.

Hi,

I defined in_PolicyID with type = global variable and set the global variable in the default.
image
This is working fine for other object repositories. I also tried replacing it as a local variable and set the value in the default, but it’s still giving the 500 internal server error.

Ah, ok… well, then, something strange happens when the object is doing the interpolation, i guess.
Honestly speaking, I never used parametrization in the body directly, as you do, for this case I usually use a totally different approach, will check the forum and revert.

1 Like

Thank you, appreciate your help.

The issue is fixed by replacing all the \\ in line 15 to \\\

@roma.taju you have a pretty complex body, so if I will be in your shoes I will use a different approach.
E.g I will store the body template as a file, and do the needed substitutions from a testcase, using the groovy SimpleTemplate engine.
see: Template engines

I made an example of how this can be achieved some time ago, here:

So I suggest to you to build the entire body in a testcase and pass it to the testobject as a single string variable.

Will check this out. Thank you for the suggestion.