Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Mandatory variables are required

David Cross
Tera Expert

Hello all, While using POST in API to raise a catalog via rest api... It's giving me this error Message : mandatory variables are required But I have filled all the variables in the request body but still I'm getting this error.. Please help

2 REPLIES 2

Shriram Joshi
Tera Guru
Tera Guru

Hi David,

I have got these 2 links for your reference please do check if this answers your issue.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0790938

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0684628

 

Mark this as helpful and accepted solution if it helped you..

 

Thanks,

Shriram


BR,
Shriram Joshi

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

Mark this as Helpful / Accept the Solution if this helps.

Ratnakar7
Mega Sage

Hi @David Cross ,

 

Here are some steps you can take to troubleshoot and resolve the problem:

 

  1. Check Variable Names: Ensure that the variable names in your request body match the exact variable names defined in the catalog item. Even a slight difference in the variable names can cause this error.

  2. Check Variable Values: Double-check that you have provided values for all the mandatory variables in your request body. If any mandatory variables are missing values, you will encounter this error.

  3. Variable Data Type: Verify that the data types of the values you are sending in the request match the expected data types of the variables in the catalog item. For example, if a variable is expecting a number, make sure you are sending a number in the request.

  4. Nested Variables: If your catalog item includes nested variables (variables within variables), ensure that you are correctly structuring the JSON in the request body to represent the nested structure.

  5. Catalog Item Configuration: Check the catalog item configuration in ServiceNow. Make sure that the variables are correctly defined as mandatory or optional based on your requirements.

  6. Permissions: Ensure that the user making the API request has the necessary permissions to create catalog items and access the variables.

  7. Special Characters: If your variable values contain special characters, make sure they are properly escaped in the JSON request body.

  8. Request Format: Verify that your POST request is correctly formatted as JSON and that the headers indicate the content type as "application/json."

  9. Payload Structure: Ensure that you are sending the payload in the correct structure. The payload should be a JSON object with a "variables" field containing the variable names and their corresponding values.

  10. Debugging: Use tools like Postman or cURL to make the API request. These tools provide detailed error messages that can help identify the exact issue.

 

Thanks,

Ratnakar