Hi there,
I have a backend API with rich functionality and I want to create a proxied API with just a single call.
In my example, the backend offers a method "GET /user?email=foo@bar.org" which returns a full user object with all user data.
I want to have a single call "/userphone?email=foo@bar.org" in my proxied API which only returns the users phone number.
What I understood so far is, that I have to add a conditional flow "GET /userphone", but I currently do not have a clue how to:
- ensure, that the clients sends in a valid mail address (regex?)
- translate the /userphone to the corresponding call in the backend
- remove all data but the phone number from the backend answer
In addition, I want the proxied API to only acceppt this single method "GET /userphone" everything else should be answered by an 404-error or something similar.
Can someone gve me a basic example of how to do this?
Thanks,
Michael
@Michael Schramm , Regarding restricting unknown resources, take a look at similar article here in community.
Great Questions, Please find answers inline,
I want to have a single call "/userphone?email=foo@bar.org" in my proxied API which only returns the users phone number.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1"> <DisplayName>EV-ExtractCustom Attribute Phone Number</DisplayName> <Properties/> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <JSONPayload> <Variable name="phoneNumber"> <JSONPath>$.custom_attributes.phone_number</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">response</Source> <VariablePrefix>intercom</VariablePrefix> </ExtractVariables>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1"> <DisplayName>AM-UpdateGetUserByEmailResponse</DisplayName> <Properties/> <Set> <Payload contentType="application/json" variablePrefix="@" variableSuffix="#"> {"phone":"@intercom.phoneNumber#"} </Payload> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </AssignMessage>
How to ensure, that the clients sends in a valid mail address (regex?) ?
How to translate the /userphone to the corresponding call in the backend ?
How to remove all data but the phone number from the backend answer ?
In addition, I want the proxied API to only accept this single method "GET /userphone" everything else should be answered by an 404-error or something similar. ?
Hope it helps. Keep us posted if any.