- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 08:39 AM
Hello,
I am trying to find some information on how to create an item from my catalog via rest API. I have many items that have Variables in them that need to be filled out to capture data before submission. I have need to create items via REST. I understand that the Service Catalog API can be used to do this, but I need to set my custom created variables as well.
Example:
I have an Item called "Request Something Else". This item has three variables on the form. Those are Description and User. I need to populate these two variables with plain text. How would one go about setting up this request in the REST API Explorer for example using the Service Catalog API?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 10:57 AM
If you take a look at the Service Catalog API scripted rest api in your instance, then click into the Add Item To Cart scripted rest resource and click the documentation tab it gives you a request body example that you should be able to use to add an item to the cart with the variables populated:
{
'sysparm_quantity': 2,
'variables': {
'carrier': 'at_and_t_mobility',
'data_plan': '500MB',
'duration': 'eighteen_months',
'color': 'black',
'storage': 'sixtyfour'
}
}
The documentation for that endpoint can be found here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2019 08:25 PM
Hey Brad,
How would you set values for Variable Sets? It seems like we're able to set values for variables, but not variable sets.
Thanks!
Albert

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2019 05:35 AM
I believe you would treat the variables on the item and on the item through variable sets the same way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2019 08:22 AM
Hi Brad,
Thanks for the response. I'm trying to use the REST API Explorer with the "add_to_cart" API. I created a simple string variable and the variable and value does not come back in the response body. For this API, the documentation says, "variables Name/value pairs of all mandatory cart item variables. Mandatory variables are defined on the associated form." If I make this variable mandatory at the variable level, then I get a 400 response.
What I'm doing wrong?
Albert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 09:06 PM
Can you show an example for set values for variable set in json
variable set name - 'process_detail':
value: "[{"prone_to_human_error":"Yes","percent_standardized":"25","access_unstructured_data":"Yes","percent_rule_based":"30%","process_change_frequency":"N/A"}]"
{
'sysparm_quantity':2,
'variables':{
'process_name':'test claysys process',
'process_steps': 'test1',
'notes':'testnote',
'process_name':'processtest'
}
The above is my json.Could you help me embed the variable set in it..
pls help...
Thanks in advance..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2021 08:35 PM
Hi Brad,
Could you please tell me how I can pass an array of values to a variable?
For eg:
{
'sysparm_quantity': 1,
'variables': {
'value1': ["k1":"v1", "k2":"v2"]
'value2': 'some value'
}
}