Articles in this section
Category / Section

Merge two contents from two different API calls using InvokeHTTP processor

3 mins read

Introduction

This document illustrates how to merge two contents from two different API call’s by using the InvokeHTTP processor in Syncfusion Data Integration Platform.

 

Requirement Processor

 

Processor name

Usage

InvokeHTTPProcessor

Used to get data from server API calls.

SplitJson

Used to split the input data as multiple or separate content of the array element.

EvaluateJsonPath

Used to store the attribute value from respected API call.

ReplaceText

Used to replace the original data as per the FlowFile content.

UpdateAttribute

Used to update the attribute value.

PutFile

Used to store the content of merged data on local system.

 

Workflow

              

 

Steps to merge two flow files:

Get data from web API-1 and store the attribute value

Step 1:

  • Drag the InvokeHttp processor and configure the property field of HTTP method, Remote URL, and choose the StandardSSLContextService in SSL context service field.
  • Set the required HTTP method (GET, POST) and specify API URL in Remote URL property field.
  • Specify the time in Connection Timeout property field as per requirement.

 

 

  • Map to next processor by choosing the Response field.

Step 2:

  • Drag the SplitJson processor and configure the JsonPath expression field as per requirement.

  • In this sample, you can split json as individual by giving this regular expression $.[*]. It helps to split json array as individual object.
  • Map to next processor by choosing the split option.

 

Step 3:

  • Drag the EvaluateJsonPath processor and choose the flowfile-attribute from the Destination property field.
  • This processor is helpful to store the attribute value from respected API call. Here, it stores the attribute values from split json.
  • By clicking the add button, you can include the properties in the configuration list.

 

  • Specify the property value as $.<yourJsonPropertyName>.

 

 

Note:

 

For example, if you want to store the property values as attribute from json file, refer the tabulation as follows.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sample Json

Property Name

Property Value

Id

name

username

email

website

$.Id

$.name

$.username

$.email

$.website

 

 

  • Map to next processor by choosing the matched option.

Get data from web API-2 and store the attribute value

Step 4:

  • Drag the InvokeHTTPProcessor and configure the properties as same as step 1.
  • In the Remote URL field, specify the respected another web API URL and append the attribute value in same. You can specify any attribute name based on requirement.

 

Step 5:

  • Drag the EvaluateJsonPath processor and choose the flowfile-attribute from the Destination property field.
  • It’s same as Step 3, and add property field and value to store the attribute value from API call-2.

 

 

Merge data from API-1 and API-2 and store on local system

Step 6:

  • Drag the ReplaceTextProcessor and configure the replacement value property field.
  • Fill the saved attribute names from API call-1 and API call-2.

Replacement value in this sample as:

 

${id},${name},${username},${email},${phone},${website},${title},${url},${thumbnailUrl}

 

API Call

Attribute Name

Attribute taken from web API call-1

${id},${name},${username},${email},${phone},${website}

Attribute taken from web API call-2

${title},${url},${thumbnailUrl}

 

 

  • Finally, you will get the above two contents as single response from different API call’s using this workflow.

 

Note: MergeContentFile processor is used to merge a group of FlowFiles together based on a user-defined strategy and packages them into a single FlowFile. Based on requirement, I would recommend this flow to merge two contents.

Step 7:

Drag the UpdateAtrribute processor to update the attribute value by adding the property as filename and value as any name with any extension type (optional) to store the file.

Step 8:

Drag the PutFile processor and configure the output directory path to store the merged content file in local system.

Note: Here, the output file has been saved as CSV. You can also build like a query import SQL server using the Putsql processor as per requirement.

 

Sample URL:

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied