Create request in servicenow through REST API integration using Cart API

Arindam Ghosh
Mega Guru

Gertting below error while creating request in servicenow through REST API integration using Cart API:

{"error":{"message":"Mandatory Variables are required","detail":""},"status":"failure"}>

Not sure why. Third party is sending the Payload in below format with all mandatory fields on request form:

Creation message: {
  "variables": {
    "description": "my request description",
    "short_description": "my request",
    "requested_for": "777713784fd4d8888ddab33181108885",
  },
  "sysparm_quantity": "1"
}

Appreciate your help.

1 ACCEPTED SOLUTION

Thanks for the response. The issue was with the variable name. I misspelled one variable name which caused this issue.

View solution in original post

9 REPLIES 9

To use submit_order, item should be added to cart 

Please use Buy item (order_now) end point

api/sn_sc/servicecatalog/items/{sys_id}/order_now

Thanks for the reply and as you suggested, I have used the same endpoint:

 

find_real_file.png

 

But still having the issue and this time different error(

Mandatory Variables are required) even though I have added all mandatory variables. 

 

Here is the payload:

 

{
"variables": {
"description": "test",
"dueDate": "02/16/2019 14:20:59",
"assignment_group": "f8fc1924db792b40e10974dfaa961918",
"short_description": "etest",
"requested_for": "68ec13784fd4d2003ddab3318110c7d1",
"cmdb_ci": "44e090344f620b003ddab3318110c73f"
},
"sysparm_quantity": "1",
"detail": "This is a detail"
}

 

Here is the error message:

{
  "error": {
    "detail": "",
    "message": "Mandatory Variables are required"
  },
  "status": "failure"
}



Please suggest.

Thanks,
Arindam

 

Can you check if there a label type with mandatory is set as true

find_real_file.png

If yes, you can either set it to false or pass the label type variable in request body with some dummy value

Thanks for the response. The issue was with the variable name. I misspelled one variable name which caused this issue.

Thanks you and I used the same. 

 

{
  "u_resilient_incident_id": "3033.2258201",
  "variables": {
    "description": "test",
    "dueDate": "02/16/2019 14:20:59",
    "assignment_group": "f8fc1924db792b40e10974dfaa961918",
    "short_description": "etest",
    "requested_for": "68ec13784fd4d2003ddab3318110c7d1",
    "cmdb_ci": "44e090344f620b003ddab3318110c73f"
  },
  "sysparm_quantity": "1",
  "detail": "This is a detail"
}