Rest variable substitution

Dilip Puligilla
Giga Guru

HI All

Well i am making an rest call using a service catalog item, where couple of fields need to fill as per customer request. i am using variable substitution to make it work.

Can i know how these substitution will work from the service catalog as the user give input when ordering the item rest need to be collected to create an item.

Thanks

Dilip

1 ACCEPTED SOLUTION

Valor1
Giga Guru

Use the same format as you would in a Business Rule, etc:



try {


var r = new sn_ws.RESTMessageV2('Amazon Web Services', 'get');


r.setStringParameter('action', current.variables.my_svc_cat_var1);


r.setStringParameter('version', current.variables.my_svc_cat_var1);


var response = r.execute();


var responseBody = response.getBody();


var httpStatus = response.getStatusCode();


}


catch(ex) {


var message = ex.getMessage();


}



If you're using the REST Message Workflow activity:


Screen Shot 2015-10-19 at 4.19.18 PM.png


View solution in original post

3 REPLIES 3

Valor1
Giga Guru

Use the same format as you would in a Business Rule, etc:



try {


var r = new sn_ws.RESTMessageV2('Amazon Web Services', 'get');


r.setStringParameter('action', current.variables.my_svc_cat_var1);


r.setStringParameter('version', current.variables.my_svc_cat_var1);


var response = r.execute();


var responseBody = response.getBody();


var httpStatus = response.getStatusCode();


}


catch(ex) {


var message = ex.getMessage();


}



If you're using the REST Message Workflow activity:


Screen Shot 2015-10-19 at 4.19.18 PM.png


Hi Valor,



Am trying to create a change request through REST Message Activity, when the workflow execution completes, record gets created with empty data.


When I log the Varibales , data comes from the RITM as expected. Any thoughts?



REST API, POST METHOD


Am passing variables 'as short_description=${current.variables.short_description}, cmdb_ci=${current.variables.ci}'



Regards,


Mahesh.


Are you creating a change request on the same SN System using the REST web service? If so, that's the hard way. 🙂



Just use the GlideRecord API, and eliminate a webservice call to itself. 🙂