Updating text area field with string containing line breaks  Topic is solved

Discussions relating to the REST API of Jiwa 7.

Updating text area field with string containing line breaks

Postby Joe.Thorpe » Wed Mar 16, 2022 9:47 pm

Hi,

What's the right way to insert a line break into a text area field?

My use case is I'm trying to update the CourierDetails field on SO_History, using the following HTTP request:

POST {{baseUrl}}/SalesOrders/c844592daa4a4d1ba8d2?DeliveryAddressCourierDetails=test1\r\ntest2%5Cr%5Cntest3\ntest4
The Jiwa client shows "test1\r\ntest2\r\ntest3\ntest4". I know the field can have multiple lines as you can hit Ctrl+Enter in the client to enter a newline.
Looking at the raw output, it appears to be double escaping the escape characters (the \\r\\nd bit at the end was from me inserting a newline through the client).
"test1\\\\r\\\\ntest2\\\\r\\\\ntest3\\\\ntest4\\r\\nd\"

I've had a look through the forum and Servicestack docs, I can't see an obvious way of doing it.

Cheers!
Joe.Thorpe
Occasional Contributor
Occasional Contributor
 
Posts: 19
Joined: Fri Jun 11, 2021 1:57 pm

Re: Updating text area field with string containing line bre  Topic is solved

Postby Mike.Sheen » Thu Mar 17, 2022 1:38 am

I tried this with postman - like so:

Postman.png
Postman.png (26.29 KiB) Viewed 3771 times


This resulted in the field having a line break:

Jiwa.png
Jiwa.png (32.02 KiB) Viewed 3771 times


The Fiddler capture of the request reveals Postman translated that to the typical 0D 0A pair:

Fiddler.png


What you've shown me is you're using URL parameters - so perhaps instead of your \n\r just put %0D%0A - but ideally you should dispense with the url parameters for everything except GET requests - for POST and PATCH operations set the body to be the json like shown in my Postman screenshot.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Updating text area field with string containing line bre

Postby Joe.Thorpe » Thu Mar 17, 2022 12:19 pm

Thanks Mike, that worked perfectly.

I was using url params because the Postman collection from the Jiwa OpenAPI defaults to Content-Type application/x-www-form-urlencoded.

Cheers!
Joe.Thorpe
Occasional Contributor
Occasional Contributor
 
Posts: 19
Joined: Fri Jun 11, 2021 1:57 pm

Re: Updating text area field with string containing line bre

Postby Mike.Sheen » Thu Mar 17, 2022 12:26 pm

Joe.Thorpe wrote:I was using url params because the Postman collection from the Jiwa OpenAPI defaults to Content-Type application/x-www-form-urlencoded.


That might be a configuration - because when I examine the Postman meta data I see the content headers designated as application/json:

postman meta.png


Do you see the same when visiting the /postman route, - does yours show "headers":"Accept: application/json"?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Updating text area field with string containing line bre

Postby Joe.Thorpe » Thu Mar 17, 2022 12:31 pm

Ah yeah it's application/json there, so i did something wrong when I imported the collection. All good, i'll figure it out.
Joe.Thorpe
Occasional Contributor
Occasional Contributor
 
Posts: 19
Joined: Fri Jun 11, 2021 1:57 pm


Return to REST API

Who is online

Users browsing this forum: No registered users and 1 guest