REST API Connector Guide > REST API Operations > Making a GET Request
  

Making a GET Request

You are a weather analyst. Using Informatica Cloud, you want to use a RESTful service to read the weather data of any city for analysis.
In this example, you pass the required city names as data filters, receive the JSON message format output, and write the output to a .csv file. Perform the following steps:
  1. 1. Create a REST API Connection to use as a source.
    1. a. Create a URL input parameters config file.
    2. b. Use the URL input parameters config file in the connection.
  2. 2. Create a Data Synchronization task.
    1. a. Configure source to access REST API endpoint.
    2. b. Configure target to write data to a flat file.
    3. c. Configure data filters.
    4. d. Map the fields.
    5. e. Save and run the Data Synchronization task.

Create a REST API Connection

    1. Click Configure > Connections.
    2. Click New to create a connection.
    The New Connection page appears.
    3. Specify the following details:
    Connection Property
    Description
    Connection Name
    Enter a unique name for the connection. For example: OpenWeather_REST
    Description
    Provide a relevant description for the connection.
    Type
    Select ReST (Informatica Cloud Labs)
    Runtime Environment
    Select the appropriate Secure Agent.
    Base URL
    http://api.openweathermap.org/data/2.5/weather
    Is Base Url Dynamic
    Checked
    Url Request Parameters
    q=bangalore;APPID=70ab007d4fe120b85d11d5432cbe7609
    Form Request Parameters
    N/A
    Header Request Parameters
    N/A
    Media Type
    Select application/json
    Request Type
    Select GET
    Authentication Type
    NO_AUTH
    Auth UserId
    N/A
    Auth Password
    N/A
    OAuth Consumer Key
    N/A
    OAuth Consumer Secret
    N/A
    OAuth Token
    N/A
    OAuth Token Secret
    N/A
    Additional Custom OAuth Parameters
    N/A
    Config File or Private Key File Name
    N/A
    Sample Response XML or JSON File Path
    N/A
    Response Folder Path
    Specify a path on the Secure Agent machine where you want to generate the response file. For example: C:\Informatica\Cloud\FlatFile_Connections\Weather
    Url Input Parameters Config File Name
    Specify the path and name of the config file. For example:
    C:\Informatica\Cloud\FlatFile_Connections\Weather\config.csv
    When the file is created for the first time, it contains the values that are provided in the Url Request Parameters field.
    Form Input Parameters Config File Name
    N/A
    Header Input Parameters Config File Name
    N/A
    Create the config csv file
    Select Yes
    4. Click Test to create the Url Input Parameters config file.
    5. Select No in the Create the config csv file parameter as shown in the following image:
    6. Click OK to create the connection.
Open the config.csv file. The following image shows the sample config file:
Add the additional parameter values with a valid syntax. The following image shows the sample config file after adding additional parameter values:
The following image shows the sample config file with dynamic base URL.

Create a Data Synchronization Task

    1. To create a Data Synchronization task, click Task Wizards > Data Synchronization, and then click New.
    2. In the Data Synchronization Task Details area, configure the following fields:
    Field
    Description
    Task Name
    Name of the Data Synchronization task. For example: REST_GetWeather_By_City
    Description
    Description of the Data Synchronization task. Maximum length is 255 characters.
    Task Operation
    Select Insert.
    3. Click Next.
    4. On the Source page, configure the following fields:
    Field
    Description
    Connection
    Select the connection you created. For example: OpenWeather_REST
    Source Type
    Select Single.
    Source Object
    Select JsonRoot.
    5. Click Next.
    6. On the Target page, configure the following fields:
    Field
    Description
    Connection
    Select the flat file connection.
    Target Object
    Click Create Target. Change the default file name to WeatherByCity.csv and select all fields in the file.
    7. Click Next.
    8. On the Data Filters page, create a new filter and filter by _FLT_URL_Input_Parameters_Config_File_Path. Provide the path and name of the config file that contains different values for different records, as shown in the following image:
    9. Click Next.
    10. On the Field Mapping page, click Automatch.
    11. Click Validate Mapping
    12. Save and run the Data Synchronization task. The following image shows the sample output:
    You can also create a mapping or Mapping Configuration task to make a GET request.
    13. Configure advanced source properties. Advanced source properties appear on the Schedule page of the Data Synchronization Task wizard.
    The following table describes the advanced source properties that you can configure for a REST API source:
    Field
    Description
    Time delay in ms
    Specifies the amount of time (milliseconds) to wait before the connector retries for a response.
    Retry Count
    Specifies the number of tries to get the response from an endpoint based on the time delay.
    Note: If the connector is not able to get response based on the time delay in ms and retry count properties, it throws an exception.