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

palanikumar
Mega Sage

Quantity should be a number. Pass like below:

"quantity"1,

Thank you,
Palani

Hi,

 

Thanks for replying. Yes, i did the same but was getting the same error.

 

Regards,

SHivani

Ajay Sharma2
Tera Guru

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

Thanks Ajay, It is working now

 

Regards,

Shivani