0

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>
ZZzzZZzz
  • 1,800
  • 3
  • 29
  • 51
  • If you're using the Users collection, it won't let you POST with a duplicate email address. Have you tried just letting the call pass through? – brandonscript Feb 24 '15 at 19:44
  • 1
    have a collection "invitereq". I have my entity as { "uuid": "3cb61b4a-bc5f-11e4-b3fe-ad9d5cff3d0b", "type": "invitereq", "created": 1424807795444, "modified": 1424807795444, "email": "qwerty@gmail.com", "metadata": { "path": "/invitereq/3cb61b4aasdbc5fsdasdsada-sd-sadsad" }, "status": "requested" } – ZZzzZZzz Feb 24 '15 at 19:59
  • 2
    If you're using a custom collection then, you'll need to call out with a GET first to check, then inspect the response and either POST to create a new one or raise a fault. – brandonscript Feb 24 '15 at 20:00
  • Any example please based on my posted xml. Thanks – ZZzzZZzz Feb 24 '15 at 20:01
  • that's just your flow steps, it's difficult to see what's going on just by looking at the flow. You'll want to look for a Service Callout policy. – brandonscript Feb 24 '15 at 20:12
  • 1
    I guess only users and usergroup collections are not allowing duplicate values. How to achieve the same with other collections. – ZZzzZZzz Feb 24 '15 at 22:13
  • See my previous comment – brandonscript Feb 24 '15 at 22:17

1 Answers1

1

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.

Joshua Dwire
  • 5,415
  • 5
  • 29
  • 50
Diego
  • 1,678
  • 1
  • 16
  • 20
  • I've removed the request to post to the Apigee Community, as it's not an answer to the question. It should be a comment instead. If you do post links to Apigee, please disclose your affiliation with the company in your answer, and possibly on your user profile. Thanks! – Joshua Dwire Sep 04 '15 at 20:16