Service Catalog Request API

Reich1
Kilo Explorer

Hi Gurus

 

Have a little bit of questions here and hopefully i can get some clarification. Is there a way to trigger a Service Catalog Request through API?? Ive tried searching in the community and i cant seem to get the answer i am looking for. I have tried the following.

Create RITM through Rest Explorer API - This works but it wont trigger the workflow...any help on how that will be great!

Create Service Catalog through Inbound Email - This works and the workflow is triggering as well. Only thing is theres no variables

Any ideas?

 

As always thanks for the help!

 

 

2 REPLIES 2

Mike Patel
Tera Sage

I did something similar with Inbound Action Email. setVariable 2nd is variables name and 3rd is value.

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e46305bdc0a8010a00645e608031eb0f'); 
cart.setVariable(item,'os','Linux Red Hat');
var rc = cart.placeOrder(); 
//gs.addInfoMessage(rc.number);

Olyn Dabbs
Tera Expert

Have you tried using the Service Catalog API to do this?

 

Go to the REST API Explorer.  Set the following values:

 

Namespace: sn_sc

API Name: Service Catalog API

API Version: latest

 

As for the request type, first select 'Add Item to Cart (POST)'.  In the field next to 'sys_id', enter the sys_id of the catalog item.  You can leave everything else up until 'Request Body' as the default value.  Under 'Request Body' select 'Raw'.  Then enter something like this as the request body.

 

{
  "sysparm_quantity":"1",
  "variables":{
    "variable_1":"value_1",
    "variable_2":"value_2",
    "variable_3":"value_3"
  }
}

Replace 'variable_x' and 'value_x' with your variables and values for the specific catalog item you're submitting.  Once the request body is filled out, click the blue 'Send' button at the bottom and click 'OK'. 

 

If you get a good reponse, then click the 'Checkout Cart' option on the left side of the explorer and again click 'Send'. 

 

Once you've done this, you should be able to go see the new record in the sc_req_item table.  There should be workflow and variables attached.

 

Hope this helps.