RITM creation via REST API

Shivani29
Mega Guru

Hi,

 

I am using POST method for Buy Item: 

https://xxxx.service-now.com/api/sn_sc/servicecatalog/items/{sys_id}/order_now

 

 and testing via postman. Below is the json I am passing via postman:

 

{
   
     "quantity": "1",
    "variables": {
        "Variable1": "value",
        "variable2": "value",
        "variable3": "value",
          }
}
 
All the mandatory fields are filled and when I test this, getting error in response body
 
"error": {
        "message": "Invalid Quantity value",
        "detail": ""
    },
    "status": "failure"
}
 
Can anyone pls help me out to get this issue resolved.
 
Thanks & Regards,
Shivani

 

 

2 ACCEPTED SOLUTIONS

Ajay Sharma2
Tera Guru

@Shivani29  - Try replacing   "quantity""1" with "sysparm_quantity": "1"

View solution in original post

Aniket Chavan
Tera Sage
Tera Sage

Hello @Shivani29 ,

 

The error you're seeing suggests that the quantity field is being passed incorrectly. For the REST API request to work properly, the quantity field should be sent as an integer, not as a string.

 

Here are two options you can try:

  1. Send quantity as an integer:

    {
        "quantity": 1,
        "variables": {
            "Variable1": "value",
            "variable2": "value",
            "variable3": "value"
        }
    }
    
  2. Use sysparm_quantity instead of quantity:

     

    {
        "sysparm_quantity": 1,
        "variables": {
            "Variable1": "value",
            "variable2": "value",
            "variable3": "value"
        }
    }
    ​

Either approach should resolve the "Invalid Quantity value" error. Let me know if you encounter any other issues!

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.


Regards,
Aniket

View solution in original post

9 REPLIES 9

Moin Kazi
Kilo Sage
Kilo Sage

Hi @Shivani29 

 

Instead of quantity could you please use sysparm_quantity

See below -

{
   
     "sysparm_quantity"1,
    "variables": {
        "Variable1""value",
        "variable2""value",
        "variable3""value",
          }
}
 

 

Please mark my answer as correct and helpful if it works for you.

 

Regards

Moin

Rajesh Chopade1
Mega Sage

Hi @Shivani29 

 

Ensure that the quantity field is being sent as an integer rather than a string. You can modify your JSON to

{
    "quantity": 1,
    "variables": {
        "Variable1": "value",
        "variable2": "value",
        "variable3": "value"
    }
}

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh

 

 

Aniket Chavan
Tera Sage
Tera Sage

Hello @Shivani29 ,

 

The error you're seeing suggests that the quantity field is being passed incorrectly. For the REST API request to work properly, the quantity field should be sent as an integer, not as a string.

 

Here are two options you can try:

  1. Send quantity as an integer:

    {
        "quantity": 1,
        "variables": {
            "Variable1": "value",
            "variable2": "value",
            "variable3": "value"
        }
    }
    
  2. Use sysparm_quantity instead of quantity:

     

    {
        "sysparm_quantity": 1,
        "variables": {
            "Variable1": "value",
            "variable2": "value",
            "variable3": "value"
        }
    }
    ​

Either approach should resolve the "Invalid Quantity value" error. Let me know if you encounter any other issues!

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.


Regards,
Aniket

Ravi Gaurav
Giga Sage
Giga Sage

Hi @Shivani29 

In ServiceNow's REST API, the quantity might need to be passed as an integer instead of a string. Try removing the quotes around the quantity value, like this:

{
"quantity": 1,
"variables": {
"Variable1": "value",
"variable2": "value",
"variable3": "value"
}
}

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Tai Vu
Kilo Patron
Kilo Patron

Hi @Shivani29 

Replace quantity by sysparm_quantity should do the trick.

Screenshot 2024-10-14 at 16.54.20.png

 

Invalid quantity value: Indicates that either the sysparm_quantity parameter is not provided or contains an invalid value.

Ref: ServiceNow Catalog API - Invalid quantity value

 

Cheers,

Tai Vu