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.

How to pass user name instead of sys_id in REST API Explorer using Service Catalog API.

sri2020
Kilo Contributor

Hi,

 

I am trying to create catalog request using this REST API -/api/sn_sc/servicecatalog/items/{sys_id}/order_now 

i used Buy Item (Post)

Catalog is getting created successfully when I am passing this query parameter   -

{"sysparm_quantity":"1","variables":{"description":"TESTING REST API EXPLORER","requestor_information":"true","requested_for":"f3b4d485db499010bdcfd5ab5e961972"},"sysparm_item_guid":"d9bcc9bc1b4e94108dbf42eddc4bcbd2","get_portal_messages":"true","sysparm_no_validation":"true"}

But instead of sys_id of 'requested_for', I want to pass name of the user. Please help.

 

Regards

Sri 

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Sri - Give it a try

{"sysparm_quantity":"1","variables":{"description":"TESTING REST API EXPLORER","requestor_information":"true","requested_for.user_name":"PASS USER NAME"},"sysparm_item_guid":"d9bcc9bc1b4e94108dbf42eddc4bcbd2","get_portal_messages":"true","sysparm_no_validation":"true"}

View solution in original post

7 REPLIES 7

Hi @Pradeep Sharma , 

We have the same requirement,  Trying to submit the catalog item from API call by using service catalog API.
when i use the below request body with the userID instead  of sys_id  for requestor, it was giving the result of the variable as EMPTY. 

Could you please help me out of this.
{"sysparm_quantity":"1","variables":{"description":"TESTING REST API EXPLORER","requestor_information":"true","requested_for.user_name":"My USER ID"}

 

HI Pradeep Sharma & Team,
Thank you for your suggestion. But this solution is not working for us. Could you please re-confirm and help us if its the right way or if there are any other workarounds without customizing the Order_Now API will be really value adding for most of the users consuming this feature.

 

Thank you,

Selva.

sri2020
Kilo Contributor

Hi Pradeep,

 

Thank much.. 

I have given some one else name .. Still Requested for is taking my name ..

 

I have taken this request pay load from self service . Is that the reason..?

 Requestedfor should be based on selection/ passed value.

Please help/suggest..

Regards

Sri