Issue when passing dynamic values to REST API activity when values have line breaks in it

Hello Everyone,

I having a query related to assigning dynamic parameter values to “REST API Activity”.

I am facing issues invoking API when dynamic values passed to the API are long string with /r/n in it.
Dynamic values with string not having /r/n have no issues but when the value contains line break i.e. /r/n it returns 500 error.

I tried same value passed through postman which got success without issue.

Dynamic values are passed as below,

  • REST API activity -> Settings - > Input Mapping -> Request Type -> RAW

{“Requested by”:"#requestedBy#"}
** in above line dynamic value is passed as “hashDollar requestedBy hashDollar”. (not sure why Dollar symbol is not visible)
where if,
requestedBy = “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.” - there is no issue

if
requestedBy = “Lorem ipsum dolor sit amet, /r/n
consectetur adipiscing elit, sed do eiusmod /r/n
tempor incididunt ut labore et dolore magna aliqua.” - gives error

Kindly help if there is way handling such cases.

Hi,

How are you giving carriage return in a argument value. Do a write line of the argument that you are passing to check if value is correct

Regards,
Amit Anand

Hello @amit_anand15,

I tried printing the value of an argument, when there is /r/n in the argument (i.e. new line in the text provided), it gives error invoking the API.

Same value using POSTMAN work fine.

And I have attached screenshot in my query fr show the way I am passing the parameter.

I would appreciate if you can help here…if there is a way to handle this case.

Hi,

Can you print the value of requestidBy argument using WriteLine activity and post the screenshot.

Regards,
Amit Anand

output

Hello @amit_anand15

Requested By is one of the parameter which will have values as “Ameya Prabhune”

The issue arises when the value in justfication parameter is passed which has new line, line breaks.
For example, the value passed to justification is as follows(with exact new lines/line break) which is printed in writeline as well

Justification: "This change is very criticle to be implemented.
This will have business impact if not implemented.

Thanks"

When a value with new lines is passed, it returns 500 error. On the other hand if justification value is passed without any new lines, it returns success.

I thought it was API issue, and tried passing same values using POSTMAN, it gave me success even when justification value was with new lines. So this seems issue at RPA end.

Please have a look if you can assist.

POSTMAN input param is also attached.

Hi,

In postman you have used \r\n which it is able to parse.
In RPA tool try using Environment.NewLine for string formation to give new line character

Regards,
Amit Anand

Hi @amit_anand15,

Thanks for that update.

I am somewhat new to RPA world. Could you please assist me how & where to set Environment.NewLine ?

Appreciate your time and help.

Thanks.

Thanks ! @amit_anand15

The issue is resolved using Environment.Newline.

For a string, I have checked if there are New Lines. If yes, I replaced it with /r/n
This has resolved the issue when passing such strings as input to API.

Thanks.