Parse Policy in API Connect
In this blog, we will learn about Parse policy in IBM API Connect.
1. Parse Policy
The purpose of this document is to provide a Brief understanding of Parse Policy use cases and How to implement the same in IBM API Connect.
The Parse policy is used to extract information from the request or response message and make it available for further processing in the API assembly in API Connect.
1.1Advantages of using Parse Policy
Data Extraction: The Parse policy allows for easy extraction of specific data elements from the request or response messages, enabling manipulation and transformation of the extracted data within the API assembly.
Flexibility: It provides flexibility in handling different data formats, including JSON, XML, and other message formats, allowing for the extraction of relevant data fields regardless of the message structure.
Simplified Data Processing: The policy simplifies the process of accessing and manipulating data, making it easier to work with specific elements without having to handle the entire message structure.
Enhanced Security: By enabling the extraction of specific data fields, the Parse policy can contribute to enhanced security by allowing the filtration and validation of data before it proceeds through the API flow.
1.2 Disadvantages of using Parse Policy
Complex Message Structures: In cases where the message structure is complex or nested, extracting specific data elements using the Parse policy may require in-depth knowledge of the message structure, potentially leading to complexities in the configuration.
Potential Data Loss Risks: Incorrect configuration of the Parse policy can lead to the unintended loss of data or the extraction of incorrect data elements, potentially impacting the integrity and reliability of the processed data.
Performance Overhead: When dealing with large messages or a high volume of requests, the use of the Parse policy for extensive data extraction and manipulation may introduce performance overhead and impact the overall processing speed of the API.
Configuration Complexity: Understanding the intricacies of the Parse policy and its configuration settings may require a learning curve, especially for users who are not familiar with the specific details of the API Connect platform and its policies.
2. Architectural Requirements.
2.1 IBM API Connect
All of the steps in the API lifecycle and the activities that surround them are carried out inside IBM API Connect, an integrated API management solution.
With IBM API Connect, you can perform all of the lifecycle steps in a single integrated offering, removing the requirement to use multiple API management offerings to obtain the same capability.
2.2 Procedure to Create Parse Policy API
- Create an API in IBM API Connect.
- First add the Policy and then after add the Invoke policy.
- In the Invoke Policy we used the Loopback URL.
- Apply the changes for Parse Policy as discussed bellow
3. Parse Policy Assembly Diagram
- When we configure the “Use Content-Type” option in policy whenever we pass the Header Content-Type is “application/JSON” and we passing the Body is XML.
- When we configure the Use “Content-Type” option in Parse policy whenever we pass the Header Content-Type is “application/XML” and we passing the Body as JSON It stops the Flow and shown the error as shown below.
It is working fine whenever we the Content-Type and Payload formats are same.
Whenever we select the Parser Settings in DataPower we able to modify respective parser name.
If you want to add another settings object first create in Data Power then after add in the API.
If we need to parse the Incoming Request we need to configure “Message for parsing” like below
After it was done we can keep the data in “Message for resulting parsed data” variable default it is input name as it is so here also it keeps the data in “message.body” Context variable.
After Parsed Successfully the resultant data can be passed to the Next policy for further use.