REST API Reference > Data Integration REST API > Hierarchical mappers
  

Hierarchical mappers

Use the h2h resource to create or run a hierarchical mapper that converts hierarchical data to a different hierarchical structure.
The h2h resource uses a hierarchical mapper ID in the URI. To find the hierarchical mapper ID, open the hierarchical mapper in the Data Integration user interface. In the URL, the last string of characters is the hierarchical mapper ID.
For example, in the URL https://dm-us.informaticacloud.com/diUI/products/integrationDesign/main/idsm/7sQJvjkeZLIfpWg6hpYwqJ/read, the hierarchical mapper ID is 7sQJvjkeZLIfpWg6hpYwqJ.

Creating a hierarchical mapper

To create a hierarchical mapper, send a POST request and specify the hierarchical mapper details.

POST request

Use the following URI to create the hierarchical mapper:
/h2h/api/v1/create/<hierarchical mapper ID>
The following table describes the fields in the POST request:
Field
Type
Description
name
String
Name of the hierarchical mapper.
description
String
Description of the hierarchical mapper.
projectName
String
Project where you want to save the hierarchical mapper.
projectFolderPath
String
Folder within the project where you want to save the hierarchical mapper.
sourceXsd
String
Source XSD file, such as EDI832__20190322_140316.xsd
sourceXsdDependencies
Array
List of dependencies for the source XSD file.
targetXsd
String
Target XSD file, such as X12_4010_810.xsd
targetXsdDependencies
Array
List of dependencies for the target XSD file.
sourceRoot
String
Name of the root element in the source.
targetRoot
String
Name of the root element in the target.
variables
Details about variables. The variables object includes the name, type, list indicator, and initial value.
name
String
Variable name.
type
String
Variable data type.
list
Boolean
True or false.
initialValue
String
Initial value of the variable.
statements
String
Comma-separated list of statements in the hierarchical mapper.
encodedService
String
Base64-encoded ZIP file that contains the source and target XSD files for the source and target schemas, as well as the dependencies of those XSD files.

POST response

If successful, the API creates the hierarchical mapper.

POST request example

The following example shows a request to create a hierarchical mapper:
POST <serverUrl>/h2h/api/v1/service/create
IDS-SESSION-ID: 689EaCniaW9b0YgwET5DwU
Content-Type: application/json

{
"name": "MigAsset2",
"description": "Migrated service",
"projectName": "Interfor_Mapping",
"projectFolderPath": "C:_Informatica_XMap_Interfor",
"sourceXsd": "EDI_810_0_2_0_2_0_0.xsd",
"sourceXsdDependencies": [],
"targetXsd": "X12_4010_810_schema_restricted_0_0_0_1_0_0_0_0_0_1.xsd",
"targetXsdDependencies": [
"X12_4010_810_schema_segments_restricted_0_1_0_2_0_1_0_1_0_2.xsd"
],
"sourceRoot": "DTedi810",
"targetRoot": "x12:interchanges",
"variables": [
{
"name": "IT_CTR",
"type": "xs:integer",
"list": false,
"initalValue": "0"
},
{
"name": "CTT_1",
"type": "xs:integer",
"list": false,
"initalValue": "0"
}
],
"statements": "[{\"output\":\"interchange/x12:TS_810\",\"mode\":\"Add\",\"input\":\".\",\"onFail\":\"propagate\",\"statementType\":\"Group\",\"name\":\"INPUT_LOOP\",\"skip\":true,\"statements\":[{\"output\":\"ST\",\"mode\":\"Add\",\"input\":\"InvoiceHeader\",\"onFail\":\"Skip\",\"statementType\":\"Group\",\"name\":\"ST\",\"skip\":true,\"statements\":[{\"output\":\"R01\",\"mode\":\"Add\",\"input\":\"'810'\",\"onFail\":\"propagate\",\"statementType\":\"Map\",\"name\":\"1\",\"skip\":false,\"statements\":[],\"statementNumber\":3},{\"output\":\"R02\",\"mode\":\"Add\",\"input\":\"invNum\",\"onFail\":\"propagate\",\"statementType\":\"Map\",\"name\":\"2- for now it's default value\",\"skip\":false,\"statements\":[],\"statementNumber\":4}],\"statementNumber\":2},{\"output\":\"BIG\",\"mode\":\"Add\",\"input\":\"InvoiceHeader\",\"onFail\":\"Skip\",\"statementType\":\"Group\",\"name\":\"BIG\",\"skip\":true,\"statements\":[{\"output\":\"R01\",\"mode\":\"Add\",\"input\":\"replace(invDate,'-','')\",\"onFail\":\"propagate\",\"statementType\":\"Map\",\"name\":\"1\",\"skip\":false,\"statements\":[],\"statementNumber\":6},{\"output\":\"R02\",\"mode\":\"Add\",\"input\":\"invNum\",\"onFail\":\"propagate\",\"statementType\":\"Map\",\"name\":\"2\",\"skip\":false,\"statementNumber\":7},[...]",
"encodedService": "UEsDBBQACAgIALiUSlkAAAAAAAAAAAAAAAAdAAAAb[...]"
}
The statement and encoded service values are truncated for brevity.

Running a hierarchical mapper

To run a hierarchical mapper, create a POST request and specify the XML or JSON data for the hierarchical mapper to process. You can provide the data as a buffer in the request body or as a file to pass to the hierarchical mapper. The output can be a buffer that is returned in the response, or you can write the output to a file.

POST request

Use the following URI to run the hierarchical mapper:
/h2h/api/v1/service/run/<hierarchical mapper ID>
The following table describes the fields in the POST request:
Field
Type
Description
agentGroupId
String
Runtime environment to run the hierarchical mapper.
If you don't specify a runtime environment, the hierarchical mapper runs natively on the Cloud Server.
input
Input details.
type
String
Type of input to send in the request body. Use buffer or file.
value
String
Input value to pass to the hierarchical mapper. If the input is a buffer, enter the XML or JSON data. If the input is a file, enter the path to the file.
output
Output details.
type
String
Type of output to receive in the response. Use buffer or file.
value
String
Output to receive in the response. If the output is a buffer, use an empty string. If the output is a file, enter the path to the file.

POST response

If successful, the hierarchical mapper returns the data in the target hierarchical structure.
The following table describes the fields in the response:
Field
Type
Description
output
String
Output value. The output is either a buffer or the path to a file.
message
String
Response message, such as Success.

POST request example for buffer to file

The following request runs a hierarchical mapper that converts XML data as a buffer and stores the converted data in an output file:
POST <server URL>/h2h/api/v1/service/run/<hierarchical mapper ID>
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID: jpaybAKQMsmdt7vLJ02z0

{
"agentGroupId": "016GOR25000000000005",
"input": {
"type": "buffer",
"value":"<?xml version=\"1.0\" encoding=\"UTF-8\"?><HL7:MSH><MSH.1>1</MSH.1><MSH.2>^~\\&amp;</MSH.2><MSH.3><HD.1>GHH_ADT</HD.1></MSH.3><MSH.7>20080115153000</MSH.7><MSH.9><MSG.1>ADT</MSG.1><MSG.2>A01</MSG.2><MSG.3>ADT_A01</MSG.3></MSH.9><MSH.10>0123456789</MSH.10><MSH.11><PT.1>P</PT.1></MSH.11><MSH.12><VID.1>2.6</VID.1></MSH.12><MSH.16>AL</MSH.16></HL7:MSH>"
},
"output": {
"type": "file",
"value": "/root/idsm"
}
}
If successful, you receive the following response:
{
"output": "/root/idsm/hmapper_runtime_api_5040_output.xml",
"message": "Success"
}

POST request example for file to buffer

The following request runs a hierarchical mapper that converts XML data in a file and returns the output as a buffer in the response:
POST <server URL>/h2h/api/v1/service/run/<hierarchical mapper ID>
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID: jpaybAKQMsmdt7vLJ02z0

{
"agentGroupId": "016GOR25000000000005",
"input": {
"type": "file",
"value":"/root/idsm/2.6_parser_response.xml"
},
"output": {
"type": "buffer",
"value": " "
}
}
If successful, you receive the following response:
{
"output": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Departments>\r\n<Department name=\"\">\r\n<Employee>\r\n<Profile>\r\n<Id>0</Id>\r\n<FullName>1</FullName>\r\n<Skills>\r\n<FHIR4></FHIR4>\r\n<XYZ></XYZ>\r\n<hl7></hl7>\r\n<HIPAA></HIPAA>\r\n</Skills>\r\n</Profile>\r\n</Employee>\r\n</Department>\r\n</Departments>\r\n",
"message": "Success"
}