SD API: Set mandatory fields. Implement error messages for missing fields.

Hi All,

Need help and guidance for the issue we are facing detail mention below,

Description: We are encountering an issue with our API that validates incoming JSON requests against an XSD schema. The API is designed to return specific error messages when mandatory fields are missing from the payload. Backend we are connecting with CPI, we don’t want to process the request without mandatory field and we make sure send the missing mandatory field information through policies.

Requirement: When a source system sends a payload that is missing a value in any mandatory field or lacks a mandatory field altogether, the API should return an error message. The recommended messages are:

Specific: “Field X is missing from the request.”Generic: “A mandatory field is missing from the request.” (if identifying the specific field is too complex).

Solution Design: We have defined the JSON (or XML) schema with the mandatory fields based on our specifications. The validation is set up to occur either at the API layer or later in the iFlow.

We are using the Message Validation policy in SAP API Management to ensure that the XML schema is validated and that the message is well-formed. 

Current API Policy Sequence:

VerifyOauthVerifyAPIKeyJSONtoXMLMessageValidation

Issue: We are encountering the following error during the Message Validation policy step: Error: “Variable request.content does not resolve to a Message.”

Request for Assistance:

 

Clarification: Could you provide guidance on how to correctly reference the request content in the Message Validation policy? We want to ensure that the JSON payload with mandatory elements is properly validated against our XSD schema.Error Handling: We would like advice on how to configure the error messages effectively, so the sender receives clear feedback regarding any missing mandatory fields.Please let me know for any further details for more clarity.

Br,
Rizu. 

​ Hi All,Need help and guidance for the issue we are facing detail mention below,Description: We are encountering an issue with our API that validates incoming JSON requests against an XSD schema. The API is designed to return specific error messages when mandatory fields are missing from the payload. Backend we are connecting with CPI, we don’t want to process the request without mandatory field and we make sure send the missing mandatory field information through policies.Requirement: When a source system sends a payload that is missing a value in any mandatory field or lacks a mandatory field altogether, the API should return an error message. The recommended messages are:Specific: “Field X is missing from the request.”Generic: “A mandatory field is missing from the request.” (if identifying the specific field is too complex).Solution Design: We have defined the JSON (or XML) schema with the mandatory fields based on our specifications. The validation is set up to occur either at the API layer or later in the iFlow.We are using the Message Validation policy in SAP API Management to ensure that the XML schema is validated and that the message is well-formed. Current API Policy Sequence:VerifyOauthVerifyAPIKeyJSONtoXMLMessageValidationIssue: We are encountering the following error during the Message Validation policy step: Error: “Variable request.content does not resolve to a Message.”Request for Assistance: Clarification: Could you provide guidance on how to correctly reference the request content in the Message Validation policy? We want to ensure that the JSON payload with mandatory elements is properly validated against our XSD schema.Error Handling: We would like advice on how to configure the error messages effectively, so the sender receives clear feedback regarding any missing mandatory fields.Please let me know for any further details for more clarity.Br,Rizu.   Read More Technology Blogs by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author