setStringParameter & setQueryParameter

Ratan B
Tera Contributor

Hi All,

What is the use & difference between setStringParameter & setQueryParameter ?
Please help with some use case if any..

Thanks is advance...

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hello,

setQueryParameter -

Appends a parameter to the end of the request URL with the form name=value.

For example, the code setQueryParameter("sysparm_query","active=true^ORDERBYnumber^ORDERBYDESCcategory"); appends the text sysparm_query=active=true^ORDERBYnumber^ORDERBYDESCcategory to the request URL.

refer - Doc

 

setStringParameter -

Sets a REST message function variable with the specified name from the REST message record to the specified value.

XML reserved characters in the value are converted to the equivalent escaped characters. To set simple string values such as sys_created_by which won't have special characters

Example,
var sm = new sn_ws.RESTMessageV2("<REST_message_record>","get"); 
sm.setStringParameter("s","NOW");

refer - Doc

 

Thanks & Regards,

Akshay

View solution in original post

4 REPLIES 4

Kartik Sethi
Tera Guru
Tera Guru

Hi @Ratan B 

 

Please go through the RESTMessageV2 API documentation given on the Developer site.

setStringParameter(String name, String value)

Sets a REST message function variable with the specified name from the REST message record to the specified value.

XML reserved characters in the value are converted to the equivalent escaped characters. Use setStringParameterNoEscape to set a variable without escaping XML reserved characters.

 

setQueryParameter(String name, String value)

Appends a parameter to the end of the request URL with the form name=value.

For example, the code setQueryParameter("sysparm_query","active=true^ORDERBYnumber^ORDERBYDESCcategory"); appends the text sysparm_query=active=true^ORDERBYnumber^ORDERBYDESCcategory to the request URL.

 


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik

Community Alums
Not applicable

Hello,

setQueryParameter -

Appends a parameter to the end of the request URL with the form name=value.

For example, the code setQueryParameter("sysparm_query","active=true^ORDERBYnumber^ORDERBYDESCcategory"); appends the text sysparm_query=active=true^ORDERBYnumber^ORDERBYDESCcategory to the request URL.

refer - Doc

 

setStringParameter -

Sets a REST message function variable with the specified name from the REST message record to the specified value.

XML reserved characters in the value are converted to the equivalent escaped characters. To set simple string values such as sys_created_by which won't have special characters

Example,
var sm = new sn_ws.RESTMessageV2("<REST_message_record>","get"); 
sm.setStringParameter("s","NOW");

refer - Doc

 

Thanks & Regards,

Akshay

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Ratan,

setStringParameter() will set the variable that can be replaced by a script. Variables can be used anywhere in the uri.

e.g. "id" is a variable.

http://myserver.mycompany.com/offices/${id}

setQueryParameter() will set the parameter. In Scripted REST API, Query Parameter needs to be set. Parameters are in form of "<parameter name>=<value>" and is appended to the uri.

e.g. "filename=image.jpg" is a parameter

http://myserver.mycompany.com/offices/filename=image.jpg

maddyluoma
Kilo Contributor

I have some questions about Uk49s Lunchtime Lottery. I am telling this question in this thread. These questions are given below:

1. What is the most common winning numbers?
2. How to participate in Uk49s lunchtime Lottery?
3. Is It Legit to play or not?

If someone has information has Uk49s Lottery tell me below. I am very confused.