REST Access to Multi-Row Variable Sets (MRVS)

Mike McCall
Giga Guru
  • The Internet has a lot of resources around ServiceNow's Service Catalog and Table REST APIs.
  • The Internet also has a growing number of resources around ServiceNow's Multi-Row Variable Sets (MRVSs).

 

What I can't find are mentions of getting or setting values within an MVRS using a REST API. When I try pulling an RITM with "variables.[my MRVS name]," I get back an empty string.

 

Does anyone know if we can or can't access Multi-Row Variable Set values through an out-of-box REST API?

1 ACCEPTED SOLUTION

Mike McCall
Giga Guru

UPDATE: I just successfully put values into the MRVS using the Buy Now API!

Here's the request body I included (using the raw JSON option in Postman):

{
    "sysparm_quantity": 1,
    "variables": {
        "products": "[{\"product_name\":\"test!\"},{\"product_name\":\"test 2!\"}]"
    }
}

In my catalog item, "products" is the MRVS name and "product_name" is the name of a variable in that set.

The syntax around quotations is essential (since the entire value assigned to "products" is a single JSON string).

View solution in original post

5 REPLIES 5

Mike McCall
Giga Guru

UPDATE: I just successfully put values into the MRVS using the Buy Now API!

Here's the request body I included (using the raw JSON option in Postman):

{
    "sysparm_quantity": 1,
    "variables": {
        "products": "[{\"product_name\":\"test!\"},{\"product_name\":\"test 2!\"}]"
    }
}

In my catalog item, "products" is the MRVS name and "product_name" is the name of a variable in that set.

The syntax around quotations is essential (since the entire value assigned to "products" is a single JSON string).

So if there were multiple variables for a row how would that look.  In your example if products had multiple variables such as product_name, product_description for each row. ?   

 

Good question! Using the latest Order Now API, my guess is to make this your JSON request body:

 

 

{
    "sysparm_quantity": 1,
    "variables": {
        "products": "[{\"product_name\":\"test!\",\"product_description\":\"first product description\"},{\"product_name\":\"test 2!\",\"product_description\":\"second production description\"}]"
    }
}

 

 

 

I didn't actually test that, but I'd hope you could add more name-value pairs within each curly-braced "row"--separated by just a comma. I'm curious to know if that works!

Karthick Nagara
Tera Expert

Hi Mike,

how did you manage GET call for MRVS

Were you able to do a GET with variables.[MRVS name] ?