How do I pass text containing utf-8 new line characters as a value to a parameter for a REST request

Originally posted by rramesh on August 09, 2017

Hi,

I need to enter text comprising of newline characters as a parameter value for a REST request in SOAPUI.

The API accepts this data in UTF 8 format.

How do I actually represent new line characters as part of my test data that would be passed as a value to a parameter for the REST request?

Any help would be greatly appreciated.

Thanks,

Ramesh

Originally posted by sanj on August 09, 2017

Could you not just send a string and use new liner separators?

Originally posted by rramesh on August 09, 2017

Passing the character “\n” (for newline) as part of the text for the test data does not work.

So, if I pass the text as, say, -:

Hello \n World

In the response, the text appears the same as -:

Hello \n World

and not as -:

Hello

World

Originally posted by rramesh on August 09, 2017

I also tried using ASCII characters to represent the newline and also CDATA constructs, but nothing seems to work.

Please help.

Originally posted by sanj on August 09, 2017

Try “\n”

Originally posted by rramesh on August 09, 2017

\n also does not work.

Originally posted by sanj on August 09, 2017

the following has some info on how to encode parameters

https://www.soapui.org/testing-dojo/best-practices/understanding-rest-headers-and-parameters.html

Originally posted by nmrao on August 13, 2017

Are you using windows? See if \r\n helps.

Originally posted by rramesh on August 14, 2017

\r\n too does not work.

Originally posted by sanj on August 14, 2017

\r is another way of doing new line I was not going to expect that to work

Try searching online line man I am sure someone must have solution to this one

Originally posted by PaulMS on August 15, 2017

you can use the percent-encoded value for a new line, it’s %0D%0A although %0A(ASCII 10 - line feed) or %0D (ASCII 13 - carriage return) should work alone.

https://stackoverflow.com/questions/10601672/posting-url-with-string-parameter-that-contains-line-breaks-using-java

Also disable URL encoding of the parameter value for the REST resource/method when using custom encoding in this case.

For custom encoding handling when setting a parameter value (the “Disable Encoding” setting)

https://www.soapui.org/rest-testing/rest-resources-and-methods.html