Thursday, 14 March 2019

Fetch Email attachments using Microsoft Email adapter in Oracle Integration Cloud

In the article, we'll show how to fetch the attachments from email and dump the attachments on the SFTP server.

To complete this article, we should have in place:
  1. MS email connection: If not created, use the post to create a connection with Microsoft outlook
  2.  FTP connection: If not created, use the post to create a connection with FTP
Below is the end to end use case which is demonstrated in the article:
  • Fetch the emails from MS outlook
  • Extract the attachments from each and every email
  • Dump all attachments on the SFTP server
Let's go ahead and see how to achieve this
  • Create a scheduled integration with name "GetAttachments"
  • Drop the Microsoft Email adapter just below the scheduled activity. The configuration wizard will be opened. On the very first screen enter below information and click the Next button
    • What do you want to call your endpoints: Enter the name of your choice let's say "FetchEmails"

  • Choose an operation "Get message of a folder" and simply click the Next button
  • On the last page of the wizard, simply click the Done button
  • Edit the "FetchEmails" mapper and hardcode the "Inbox" value in "folder_id" template parameter as we are fetching the email from "Inbox" only
  • Drop the "For Each" activity just below the MS email adapter and configure the below options in the opened wizard of "For Each" activity
    • Name: Enter the name of your choice, let's say "LoopEmails"
    • Repeating Element: Drop the "value" element of the $FetchEmails node
    • Current Element Name: Enter the name of your choice, let's say "CurrentEmail"
  • Drop the Microsoft Email adapter again under For Each loop. The configuration wizard will be opened. On the very first screen enter below information and click the Next button
    • What do you want to call your endpoints: Enter the name of your choice let's say "FetchAttachments"
  • Choose an operation "Get an attachment collection" and simply click the Next button. 
  • Edit the "FetchAttachments" mapper and drop the "id" element under the "$CurrentEmail" node to the "message_id" template parameter 
  • Drop the "For Each" activity just below the MS email adapter again and configure the below options in the opened wizard of "For Each" activity. This loop will be used to loop over the attachments of each and every email
    • Name: Enter the name of your choice, let's say "LoopAttachments"
    • Repeating Element: Drop the "value" element of the $FetchAttachments node
    • Current Element Name: Enter the name of your choice, let's say "CurrentAttachment"
  • Now, drop the FTP adapter inside the inner "For Each" loop. The configuration wizard will be opened. On the very first screen enter below information and click the Next button
    • What do you want to call your endpoints: Enter the name of your choice let's say "WriteAttachment"
  • On the Next screen, enter the information as below and click on the Next button
    • Select Operation: Write File
    • Select a Transfer mode: ASCII
    • Specify an Output Directory: Enter directory location where the attachments will be dumped. In our case it is "/home/opc/attachments"
    • Specify a File pattern: Let's say it is "abc.csv"
    • Enable PGP security: No
  • Select "No" from the Do you want to define a schema for this endpoint ? and click the Next button and finish the wizard
  • Edit the "WriteAttachment" mapper and do below mapping:
    • FileReference: Click on this element, drop the seeded function "decodeBase64ToReference" on this element and map the "ContentBytes" element of the "$CurrentAttachment" node
    • $CurrentAttachment->Name  ---> OutboundFTPHeaderType->fileName
  • Integration is completed now. Activate the integration. Before submitting the integration, open the outlook email box and see the emails and attachments of each and every email. In my case, we have two emails, one has two attachments and another is having a single attachment. In total, there are three attachments
  • Let's submit the integration. After completion of the integration, open the SFTP location and notice the three files should exist there

This is how attachments can be fetched from outlook Inbox and save it to the SFTP location.

Friday, 8 March 2019

Gmail adapter in Oracle integration cloud

The Gmail adapter of Oracle Integration Cloud enables us to create an integration with the Gmail application. This is one of the OOB adapters that Integration Cloud offers.

In this particular article, we'll show you how to create Gmail connection using Google Email adapter.

Prerequisites for Creating a Connection

To use the Gmail adapter, we must have access the Gmail APIs. So to access the Gmail APIs, we must create the Gmail project.

Below are the steps to create Gmail project:

  • Click on the New Project

  • Enter Project Name(ICSGmailConn) and click on the Create button
  • Once the project is created, make sure the newly created project(ICSGmailConn) is selected in the dropdown list
  • Click ENABLE APIS AND SERVICES
  • Search Gmail API and Select the same
  • Click ENABLE
  • On the right-hand side, click CREATE CREDENTIALS button
  • Click on the Credentials from the left navigation
  • Click on the Create Credentials drop down and select OAuth Client ID
  • Select Web application from the application type
  • In the Name field, specify a name for the OAuth 2.0 client ID credential
  • In the Authorized Redirect URI field, enter the following URL and click Create button
https://{ICS_HOST}:{ICS_SSL_PORT}/icsapis/agent/oauth/callback

For example:

https://icshost.mycompany.com:443/icsapis/agent/oauth/callback

  • Once created, it will give the client id and client secret. Copy and paste the same at a safe location because it would be required at the time of Connection creation
  • Optionally, we can set the Scope for Google APIs from the OAuth consent screen page

Now let go ahead and create the Gmail adapter connection.
  • Login into the Integration cloud console and move to the Connection
  • Click on the Create button and search for the Google Mail adapter and select
  • Enter connection Name(Gmail_conn) as per your choice and Click on Create button
  • Click on the Configure Security button and enter below information
    • Client Id: Enter the client id which was copied earlier
    • Client Secret: Enter the client secret which was copied earlier
    • Confirm Client Secret: Enter the client secret which was copied earlier
    • Scope: Enter the scope for which the adapter functionality is limited to as below. For the time being, enter https://www.googleapis.com/auth/gmail.readonly and click on the Provide Consent button
      • https://mail.google.com/
      • https://www.googleapis.com/auth/gmail.compose
      • https://www.googleapis.com/auth/gmail.insert
      • https://www.googleapis.com/auth/gmail.labels
      • https://www.googleapis.com/auth/gmail.modify
      • https://www.googleapis.com/auth/gmail.readonly
      • https://www.googleapis.com/auth/gmail.send

  • Clicking the Provide Consent button will take to the different window where it will ask you to enter the Integration Cloud credentials(if already not logged-in in the same window). After which, it will prompt to enter the Gmail credentials from which we have created the client id and client secret. If already logged-in select the Gmail account and click Allow button
  • Once the consent is successful, Access Allowed page will come up
  • Go back to the Integration Cloud connection page and Test. If everything is OK, the connection will reach 100%


Thursday, 7 March 2019

XMLDescriptor(oracle.ics.common.icsproject.jaxb.ICSProjectDefType

Sometimes we may encounter the error "Exception Description: No conversion value provided for the value [6.1.4] in field [@version]" during code migration from one Integration Cloud environment(Development) to another(UAT).



Cause of the error: The root cause of the error is Version different between the two environments. The source environment is  higher version(18.4.3.0.3) and the destination environment is the lower version(18.4.3.0.1)

Source environment version:



Target environment version:



Solution:

There are two solutions to the above issue.

Solution-1): Bring both the environment on the same version and then try to import the iar file to the destination. This is the recommended solution.

Solution-2): Update the version in the "project.xml" file in IAR file directly and then import to the destination instance. Below are the steps to update the version. This is not a recommended solution but may work for little time.
  • Open the IAR file which is exported from the source environment, open the project.xml file and notice the "version" attribute of the parent element. Here the version value is "6.1.4"

  • Now export one of the IAR file from the destination environment and see the "version" value in the same file. Here the version value is "6.1.3"

  • Now, update the project.xml file of the source IAR file and change the version value from 6.1.4 to 6.1.3 and then save the IAR file
  • Now import the updated IAR file to the destination environment and this time the IAR file should be imported successfully