apigeeapigee-baas

How to check for a duplicate value in Apigee BaaS


I have to post a email in Apigee baas. But, I have to validate if the email is already present in Baas. I have been trying using the below xml but did not work. I have included conditions to check if the email I provided is similar to the one already existing in Baas. how do i validate it?

    <Flow name="RequestInvite">
        <Description/>
        <Request>
            <Step>
                <FaultRules/>
                <Name>ExtractRequestInvite</Name>
            </Step>
            <Step>
                <FaultRules/>
                <Name>AssignIsUserExist</Name>
            </Step>
            <Step>
                <FaultRules/>
                <Name>JSEnvironmentConfig</Name>
            </Step>
            <Step>
                <FaultRules/>
                <Name>CallOutIsUserExists</Name>
            </Step>
            <Step>
                <FaultRules/>
                <Name>AssignRequestInvite</Name>
            </Step>
            <Step>
                <FaultRules/>
                <Name>CallOutRequestInvite</Name>
            </Step>
            <Step>
                <FaultRules/>
                <Name>ExtractRequestInviteResponse</Name>
            </Step>
        </Request>
        <Response>
            <Step>
                <FaultRules/>
                <Name>AssignInviteResponse</Name>
            </Step>
        </Response>
        <Condition>(proxy.pathsuffix MatchesPath &quot;/v1/requestinvite&quot;) and (request.verb = &quot;POST&quot;)</Condition>
    </Flow>

Solution

  • Name attribute in BaaS entities is unique. So, if you know that email will be your unique field, you could use name attribute to store the email BaaS along with any other required attributes. The next time that you submit a new entity to BaaS with the same email as the name, BaaS will reject the submission and leave the previous entity as is. You can catch that response and return a response to the client.