question

bmcmanus avatar image
bmcmanus asked amichaels edited

An iTest REST interactive session supports arrays in the json payload (i.e. ["value1"; "value2"] but in a testcase script, you get an error if you use the "[" character in the body/message section - is there a workaround?

iTestjsonarray
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

amichaels avatar image
amichaels answered amichaels edited

You should also make sure that the checkbox to "enable field replacement and substitutions" is unchecked for fields that contain special characters that would get interpreted by the Tcl interpreter. Primarily, "[","]", and "$"

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bhavani.geepalem avatar image
bhavani.geepalem answered

If we use the special characters "[" in the "Message" box under "Post Step Properties" in iTest REST based test case, it is not taking the content as expected and showing the error.

To avoid this error, could you please give a try by escaping special character "[" in the testcase script with the backslash "\" as shown in the attached screenshot.


sample.jpg (47.9 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bmcmanus avatar image
bmcmanus answered

Unfortunately, I need this file for multithreaded REST API calls and need this in a local variable. When trying to write to the variable, the system errors on the "[" and "]" brackets that I am trying to assign to the variable that will be referenced in the body. Anyone know how to work around this?

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bmcmanus avatar image
bmcmanus answered

The workaround I just found is to write the desired json payload with array (using brackets - "[" and "]") to a file and then readFile into a variable and then reference the variable in the message

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.