Create catalog request using this REST API through Service Catalog API

Mohan Mallapu
Kilo Sage

Hi All,

We have a requirement to create catalog request using this REST API with the help of Service catalog API -/api/sn_sc/servicecatalog/items/{sys_id}/order_now , Here i am using BUY ITEM(POST) call.

 

Catalog is getting created successfully with below payload 

{"sysparm_quantity":"1","variables":{"description":"TESTING REST API EXPLORER","requestor_information":"true","requested_for":"a3b4d485db499010bdcfd5ab5e961972"}}

But instead of 'sys_id' of 'requested_for', I want to pass user_name of the user. How we can achieve this.

Appreciate for the quick response. Thank You.

1 ACCEPTED SOLUTION

Thanks,. Service catalog API will only allow sys_id's for reference variables, 
I have created the custom scripted REST API to achieve this. 

View solution in original post

7 REPLIES 7

Saurav11
Kilo Patron
Kilo Patron

hello,

 

The user-name is also a unique field so you can directly pass the user_name instead of sys_id it will work like below:-

 

{"sysparm_quantity":"1","variables":{"description":"TESTING REST API EXPLORER","requestor_information":"true","requested_for":"abel.tuter"}}

 

Please mark my answer as correct based on Impact

I tried this method but the variable becomes empty after the record is created.

I see I think there are two ways from here if you want to keep it a reference field then you will need to create a scripted rest API which gives you the ability to glide and populate the variable

 

If you don't want to create a scripted rest API then change the reference field to lookup select box and keep the lookup field to username and then send the username that should work i believe.

 

Please mark my answer as correct based on Impact

Thanks,. Service catalog API will only allow sys_id's for reference variables, 
I have created the custom scripted REST API to achieve this.