raise fault if request is missing with the required fields and their values.

HI There,

I wan to trigger a custom fault in json, if email and username is missing in the request.could you pls provide a sample how to achieve this.

{ "username":"abcde" ,

"lastname":"xyz",

"email" : "afdsdf@gmail.com",

"terms": "yes" }

0 8 576
8 REPLIES 8

@Popleys

First, You will need to use the extract variables policy to read the values from the request into flow variables.

Then add a raise fault policy in your flow with a condition to check if the variables are null.

Would you mind,creating a zip and attach it over here?

How about you check the docs and try building your proxy based on the above suggestion; and then post back if you have specific issues?

Which doc your specifically refering in regards to this use case?

I am referring to the APigee docs

https://docs.apigee.com/api-platform/reference/policies/extract-variables-policy - to extract values from JSON payload

https://docs.apigee.com/api-platform/reference/policies/raise-fault-policy - to trigger the fault for condition - (email = null || username = null)

Checkmaterz10
Participant III

Hi, any suggestion on how can I return the missing fields in error response?

Hey! Welcome to the forums.  Please ask a new question.

Hi dchiesa1, I already posted a new question here: Include-the-Missing-Fields-in-Error-Response.
Hope somebody can help me. Btw, nice forum. Thank you.