Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Hi All, spaces and dots are not taking in request body in scripted rest api

Venkatesh098765
Tera Contributor

Hi All, in one of my json payload there is a field with the value as "test application", while i am trying to retrieve the data i am only getting the first name that is only test from this value test application. However i am able to create a record in my table but the problem is the record gets created with the name a only test not test application. How to avoid these spaces issues? Help me here

12 REPLIES 12

Sohail Khilji
Kilo Patron

Use .toString(); It must help...

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi Sohail,

 

You mean .toString in the scripted rest api?if yes, I already did like that if not in scripted rest api please let me know where you are suggesting to put .toString().

Hi @Venkatesh098765 

 

There might be non-printable or special characters at the end of the strings causing the truncation. Use trim() method to remove any leading or trailing whitespace.

 

 

 

var app_name = reqbody.application_name.trim();
var grp_name = reqbody.group_name.trim();
var operation = reqbody.typrofoperation.trim();