Introduction-As a beginner in SAP API management ,I have been exploring various policies in SAP API portal . In this blog post ,I have shared Extract variable policy which is used to read and parse information from a request or response and set it to the value of the variables that can be used in API proxy execution.
1.To get access_token using extract variable policy from OAuth2.0 secured proxy API and sending it to another API to have access using service callout policy.
[
{
"Name":"xyz",
"mobileno": "123456",
"postal-address": {
"streetno": "11",
"city": "New Delhi",
}
}
]
<ExtractVariables async="true" continueOnError="false" enabled="true" xmlns='http://www.sap.com/apimgmt'>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<JSONPayload>
<Variable name="mob">
<JSONPath>$.[0].mobileno</JSONPath>
</Variable>
<Variable name="city">
<JSONPath>$.[0].postal-address.city</JSONPath>
</Variable>
</JSONPayload>
<Source>response</Source>
</ExtractVariables>
<!-- This policy can be used to create or modify the standard HTTP request and response messages -->
<AssignMessage async="false" continueOnError="false" enabled="true" xmlns='http://www.sap.com/apimgmt'>
<Set>
<Payload contentType="application/json">{"Mobileno":"{mob}","City":"{city}"}</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" type="response">response</AssignTo>
</AssignMessage>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
10 | |
7 | |
5 | |
4 | |
4 | |
3 | |
2 | |
2 | |
2 |