Develop > Developer reference > REST API use-case scenario - import REST API

REST API use case scenario - import REST API

The import service supports importing record data into the EMS in either CSV or XML format. Imported data must comply with system and workflow rules for the import process to be successful.

You can access the service using one of the following URLs:

  • For CSV format: https://<serverAddress>/rest/<tenant-id>/import?entity-type=<entityType>&file-type=CSV

  • For XML format: https://<serverAddress>/rest/<tenant-id>/import?entity-type=<entityType>&file-type=XML

where entityType represents the type of record you are importing.

To import the data, use the HTTP method: POST. Set the header to be Content-Type with the value application/octet-stream.

CSV format request body

To import data in CSV format, make sure the CSV file follows these guidelines:

  • The first line of the file contains the record property names (headers) as specified in the metadata. The names must be identical to the record field names.

  • The following lines contain the data itself.

The following example can be used to create users:

FirstName,LastName,Email,Name,IsMaasUser,Upn

John,Smith,john.smith@microfocus.com,John Smith,false,john.smith@microfocus.com

John,Doe,john.doe@microfocus.com,John Doe,true,john.doe@microfocus.com

Click here to view a spreadsheet with sample CSV files for a series of records. The files should be imported sequentially according to their number.

Note The import service creates a separate record for each row of data in the CSV file.

XML format request body

To import data in XML format, make sure the XML file follows these guidelines:

  • Each property element contains a key element, which holds the record property name as specified in the metadata, and a value element, which holds the property value.

Example:

<entities xmlns="http://www.hpe.com/maas/1.0.0/import">
    <entity>
        <property>
            <key>name</key>
            <value>my name 1</value>
        </property>
        <property>
            <key>severity</key>
            <value>my severity 1</value>
        </property>
    </entity>
    <entity>
        <property>
            <key>name</key>
            <value>my name 2</value>
        </property>
        <property>
            <key>severity</key>
            <value>my severity 2</value>
        </property>
    </entity>
</entities>

Note The import service creates a separate record for each entity element in the XML file.

Related topics