REST API Issue for service-now catalog

adityamadhira
Kilo Contributor

Hi I am planning to use REST API for service   catalog in C# and facing below issue while testing. Please help me to fix this issue -

To test I navigated to "REST API Explorer"   in service now. While testing Add Item To Cart   (POST) call fails. Please refer attached screen short.

Error -

{
  "error": {
  "detail": "",
  "message": "Invalid Quantity value"
  },
  "status": "failure"
}

Please help me what the issue is?

21 REPLIES 21

esr124
Mega Contributor

Did you ever get this error resolved?   I'm having the same issue.   Adding a catalog item to the cart with the API getting the same error.   When I set the sysparm_quantity value to 1 I get the same error.


Hi Eric,



Try passing in header as below



find_real_file.png


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Eric,



curl "https://instance_name.service-now.com/api/sn_sc/servicecatalog/items/04b7e94b4f7b4200086eeed18110c7f..." \


--request POST \


--header "Accept:application/json" \


--header "Content-Type:application/json" \


--data "{\"sysparm_quantity\":\"1\"}" \


--user 'admin':'admin'



gave this response:



{
  "result": {
  "cart_id": "ad08fe9413b04b00125ad8228144b0bc",
  "subtotal": "$1,100.00",
  "items": [
  {
  "catalog_item_id": "04b7e94b4f7b4200086eeed18110c7fd",
  "quantity": "1",
  "localized_price": "$1,100.00",
  "price": "$1,100.00",
  "recurring_frequency": "Annually",
  "localized_recurring_price": "$100.00",
  "recurring_price": "$100.00",
  "item_name": "Standard Laptop",
  "cart_item_id": "40838c6713894300125ad8228144b0e0"
  }
  ]


Screen Shot 2017-09-12 at 6.34.51 PM.png


Using the REST API Explorer withing ServiceNow I was able to get the sysparm_quantity variable to be passed, but now it's giving me another error:



Mandatory Variables are required



I looked at the catalog item.   When I go to that catalog item's form and right-click and select Configure variables, there is only one variable listed: service_offering.