Articles in this section

Import data using XML

Importing data to an application that only accepts XML is possible, though it requires some simple extra steps. The only way to import data using XML is to modify the HTTP request body. This article uses the OpenAir—Jira Cloud platform template (US | EU) as an example, specifically the Jira Cloud platform issues to OpenAir project tasks flow.

Jira_openair_project_tasks_flow.png

Export

Use a source application connector to export data from your source application; we’re exporting Jira Cloud platform issues in this case. You can manipulate your data using transformations, hooks, and filters. Below is some sample data extracted from Jira:

{
  "page_of_records": [
    {
      "record": {
        "expand": "operations,versionedRepresentations,editmeta,changelog,customfield_10010.requestTypePractice,renderedFields",
        "id": "12",
        "self": "https://yourAccount.atlassian.net/rest/api/2/issue/12",
        "key": "DGT-3",
        "fields": {
          "statuscategorychangedate": "2023-12-21T23:04:11.779+0530",
          "issuetype": {
            "self": "https://yourAccount.atlassian.net/rest/api/2/issuetype/16",
            "id": "16",
            "description": "A small piece of work that's part of a larger task.",
            "iconUrl": "https://yourAccount.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/1316?size=medium",
            "name": "Sub-task",
            "subtask": true,
            "avatarId": 1316,
            "hierarchyLevel": -1
          },

You can always preview your data before you finish your export. We’ll eventually modify this dataset's ID(s), statuscategorychangedate, and description, but first, we must create the import.

Import

After exporting your JSON data from your source application, you can create an import to your destination application, in this case, OpenAir.

Before you begin

Before you start creating your import, find a few key pieces of information. You’ll need all this information to fill in your HTTP request body. The order will usually remain as listed here.

Note

The steps you need to follow may all be included in one document or website, or you may need to search to find every source. Here, we break it down into three “guides,” but they’re all available in the same OpenAir XML API PDF guide.

  1. Find your XML API request guide – Every XML request you send must include basic header information. Requirements may vary, but in OpenAir specifically, we need to include:

    1. XML header: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

    2. API_version: This will be “1.0”

    3. client: the type of client you are using to connect to the API

    4. client_ver: the version number of the client

    5. namespace: the namespace assigned to you by OpenAir (typically “default”)

    6. key: the authentication key used with the namespace

    For example, a request for the time on the server could look like this:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <request API_version="1.0" client="test app" client_ver="1.1" namespace="default" key="0123456789">
     <Time/>
    </request>
    

    Use handlebars to add details to the HTTP request body for some of this information. You can find this data in your HTTP request body resources. For example:

    <?xml version="1.0" encoding="UTF-8"?>
    <request API_ver="1.0" client="integrator.io" namespace="{{connection.http.unencrypted.namespace}} " key="{{connection.http.unencrypted.apiKey}}">

    For now, don’t worry about finding the exact handlebar information; just find the XML request formatting needed.

  2. Find your XML Authentication guide –  Access your application’s XML API guide to determine how to configure your authentication. Use handlebars to add details to the HTTP request body for some of this information. You can find this data in your HTTP request body resources. In the case of OpenAir specifically, it would look like this:

    <Auth>
        <Login>
            <company>{{{connection.http.unencrypted.companyId}}}</company>
                    <user>{{{connection.http.unencrypted.userId}}}</user>               
                    <password>{{{connection.http.encrypted.password}}}</password>
        </Login>
    </Auth>
  3. Find your application’s XML API guide – Access the XML API guide to build the HTTP body in your import. While you can build the HTTP body yourself, copying and pasting the request body into the Advanced field editor (AFE) before adding your handlebars is usually easier. In this example, we’re using Projecttask since we’re adding Jira Cloud platform issues to OpenAir as project tasks. Here’s an example of some available fields for Projecttask.

    <Projecttask>
     <id/> Unique ID. Automatically assigned by OpenAir.
     <created/> Time the record was created.
     <updated/> Time the record was last updated or modified.
     <notes/> Notes associated with the project task.
     <name/> Short description of this task.

Create your import

After finding all the key information, you must create your import. This process is fairly straightforward, but you might want to check the Celigo platform knowledge base to determine if there’s a guide on creating an import for your specific application. If there isn’t, don’t worry—more are being added daily!

HTTP request body

The most important step is adding your HTTP request body. The steps in the linked article show some basics, but adding an XML request body is slightly different.

  1. First, copy and add your request and authentication data in that order.

  2. Copy and paste your application’s XML sample request into the Advanced field editor (AFE).

In this case, the XML sample request would look something like this once added to the HTTP request body:

<?xml version="1.0" encoding="UTF-8"?>
<request API_ver="1.0" client="integrator.iop" namespace=" " key="">
        <Auth>
                <Login>
                        <company></company>
                        <user></user>
                        <password></password>
                </Login>
        </Auth>  
        <Modify type="Projecttask" enable_custom="1">
                <Projecttask>
                        <name></name>
                        <id></id>
                        <customerid></customerid>
                         <userid></userid>
                        <Jira_Issues_ID__c></Jira_Issues_ID__c>
                        <projectid></projectid>
                </Projecttask>

Now, you can either use import mapping to modify your field names before you change your request body or continue using handlebars to map your fields without customizing the names. If you choose to continue without import mapping, simply use the Resources available for your handlebar template section to “fill in” and iterate over your data. In the OpenAir example, this would look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<request API_ver="1.0" client="integrator.iop" namespace="{{connection.http.unencrypted.namespace}} " key="{{connection.http.unencrypted.apiKey}}">
        <Auth>
                <Login>
                        <company>{{{connection.http.unencrypted.companyId}}}</company>
                        <user>{{{connection.http.unencrypted.userId}}}</user>
                        <password>{{{connection.http.encrypted.password}}}</password>
                </Login>
        </Auth>
  {{#each data}}
   {{#if Jira_Issues_ID__c}}
  
        <Modify type="Projecttask" enable_custom="1">
                <Projecttask>
                        <name>{{fields.summary}}</name>
                        <id>{{customfield_10030}}</id>
                        <customerid>{{lookup "customerIdLookup" fields.project.id}}</customerid>
                         <userid>{{fields.assignee.key}}</userid>
                        <Jira_Issues_ID__c>{{id}}</Jira_Issues_ID__c>
                        <projectid>{{lookup "projectIdLookup" fields.project.id}}</projectid>
                </Projecttask>
AFE.png
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.