Setup Pega to check the mandatory fields in a json - REST call

What I would like to know is how to setup Pega to check the mandatory fields in a json that is sent as part of the incomming REST call and send appropriate return code. I tried to do that as part of "Validation" under "Advanced" tab for the property under the mapped json class, see below details.

I have a REST service which I am testing various input scenarios and see how Pega sends the response back. When I wans testing the "mandatory field" in the incomming json, I added some validation data for the property in the class that are mapped to the json. I did the below changes and when I call the REST endpoint without the required field as part of the json, I dont get any error instead I get a valid response back.


Under Advanced tab, I have the following Validation on the property accessionId

1. Max length = 5

2. Min length = 3

3. Column inclusion = Required

Pls let me know if this the right way of doing it or if there is a different way of doing it.

***Moderator Edit-Vidyaranjan: Updated SR details***

Group Tags


Keep up to date on this post and subscribe to comments

December 4, 2019 - 3:03am

Generally, you must do all your validations in the REST-service activity.

Use Obj-Validate on a service page. If fails, use OOTB "getMessages" function to set a text message in the response.

PS: veterinarian name "Dr. Nice" - awesome))

December 5, 2019 - 5:21pm

Thanks vapoz, do you have an example on how to use OOTB "getMessages" function to set a text message in the response?

December 6, 2019 - 5:18am
Response to KannanM3

Here's an example:

December 12, 2019 - 1:39pm
Response to vaspoz

Thanks Vazpos. I could get the messages using this @getMessagesAll(Primary), it works for the first time but when I send a valid request again I still get the same error response.

1. How can I reset or clear all the error messages that were captured from the previous call?

2. How can I set the error message in the "when" condition in the "Jump" call, as I dont see the option to set the error message on the false condition

December 13, 2019 - 3:54am
Response to KannanM3


Every new WS request should create new requestor with clean clipboard. Could you trace the second request? What's in the service page?

2. On a when condition one cannot set any properties. You must ue Jump logic to goto another step where you will set an error message.

Can you attach a screenshots of your WS rule + activity rule?