Friday, October 23, 2020

tREST

The tREST component sends HTTP requests to a Representational State Transfer (REST) Web service provider and gets responses correspondingly.

tREST Standard properties :

Basic settings:

Ø  Schema and Edit Schema

Ø  URL

Ø  HTTP Method

Ø  HTTP Headers

 Advanced settings :

Ø  tStatCatcher Statistics

Global Variables :

Ø  ERROR_MESSAGE: the error message generated by the component when an error occurs. This is an After variable and it returns a string. This variable functions only if the Die on error check box is cleared, if the component has this check box.

Ø  A Flow variable functions during the execution of a component while an After variable functions after the execution of the component.

Usage of settings :

Schema and Edit Schema :

©  Body: stores the result from the server end.

©  ERROR_CODE: stores the HTTP status code from the server end when an error occurs during the invocation process.

URL :

©  Type in the URL address of the REST Web server to be invoked

HTTP Method :

©  GET: retrieves data from the server end based on the given parameters.

©  POST: creates and uploads data based on the given parameters.

©  PUT: updates data based on the given parameters, or if the data does not exist, creates it.

©  DELETE: removes data based on the given parameters.

HTTP Headers :

©  Type in the name-value pair(s) for HTTP headers to define the parameters of the requested HTTP operation.

 

tStatCatcher Statistics :

©  Select this check box to gather the Job processing metadata at the Job level as well as at each component level.

Usage :

             Use this component as a REST Web service client to communicate with a REST Web service provider. It must be linked to an output component.

 

tExtractJSONFields :

                   tExtractJSONFields extracts the desired data from incoming JSON fields based on the XPath or JSONPath query.

tExtractJSONFields properties :

Basic settings :

Property type :

Ø  Built-In: No property data stored centrally.

Ø  Repository: Select the repository file where the properties are stored.

Schema and Edit Schema :

                      A schema is a row description. It defines the number of fields (columns) to be processed and passed on to the next component. The schema is either Built-In or stored remotely in the Repository.

Ø  View schema: choose this option to view the schema only.

Ø  Change to built-in property: choose this option to change the schema to Built-in for local changes.

Ø  Update repository connection: choose this option to change the schema stored in the repository and decide whether to propagate the changes to all the Jobs upon completion. If you just want to propagate the changes to the current Job, you can select No upon completion and choose this schema metadata again in the [Repository Content] window.

 

Read by :

Select a way of extracting the JSON data in the file.

Ø  Xpath: Extracts the JSON data based on the XPath query.

Ø  JsonPath: Extracts the JSON data based on the JSONPath query. Note that it is recommended to read the data by JSONPath in order to gain better performance.

JSON field :

Ø  List of the JSON fields to be extracted.

Loop Jasonpath query :

Ø  Enter the path pointing to the node within the JSON field, on which the loop is based.

Ø  Note if you have selected Xpath from the Read by drop-down list, the Loop Xpath query field is displayed instead.

Mapping :

Complete this table to map the columns defined in the schema to the corresponding JSON nodes.

Ø  Column: The Column cells are automatically filled with the defined schema column names.

Ø  Json query/JSONPath query: Specify the JSONPath node that holds the desired data. For more information about JSONPath expressions.

Ø  This column is available only when JsonPath is selected from the Read By list.

Ø  XPath query: Specify the XPath node that holds the desired data.

©  This column is available only when Xpath is selected from the Read By list.

Ø  Get Nodes: Select this check box to extract the JSON data of all the nodes or select the check box next to a specific node to extract the data of that node.

©  This column is available only when Xpath is selected from the Read By list.

Ø  Is Array: select this check box when the JSON field to be extracted is an array instead of an object.

©  This column is available only when Xpath is selected from the Read By list.

Die on error :

Ø  Select this check box to stop the execution of the Job when an error occurs.

Ø  Clear the check box to skip any rows on error and complete the process for error-free rows. When errors are skipped, you can collect the rows on error using a Row > Reject link.

Ø 

 

Advanced settings :

 

Encoding :

Ø  Select the encoding from the list or select Custom and define it manually. This field is compulsory for database data handling.

tStatCatcher Statistics :

Ø  Select this check box to gather the Job processing metadata at a Job level as well as at each component level.

Global Variables :

Ø  ERROR_MESSAGE: the error message generated by the component when an error occurs. This is an After variable and it returns a string. This variable functions only if the Die on error check box is cleared, if the component has this check box.

Ø  NB_LINE: the number of rows read by an input component or transferred to an output component. This is an After variable and it returns an integer.

Ø  A Flow variable functions during the execution of a component while an After variable functions after the execution of the component.

Ø  To fill up a field or expression with a variable, press Ctrl + Space to access the variable list and choose the variable to use from it.

Log4j :

·         If you are using a subscription-based version of the Studio, the activity of this component can be logged using the log4j feature.

Example:

Extracting a data from web using trest and tjsonfeilds.

Step 1:

 First we have to select trest component and in basic settings we have to paste the url

 

·         After that connect to tExtractJSONFeilds components

Setting up the tExtractJSONFields:

1.Double-click tExtractJSONFields to display its Basic settings view.

2.Click Edit schema to open the schema editor.

·  Click the [+] button in the right panel to add three columns, namely id, employee_name, employee_salary, employee_age, profile_image which will hold the data of their counterpart nodes in the JSON field staff.

Click OK to close the editor.

·  In the pop-up Propagate box, click Yes to propagate the schema to the subsequent components

·  Specifically, define the Json Path query "$. id " for the column id, "$. employee_name " for the column employee_name, and  “$.employee_salary” for thr coloumn employee_salary.

 

Setting up the tLogRow components :

1.Double-click data_extracted to display its Basic settings view.

·  Select Table (print values in cells of a table) for a better display of the results.

·  Perform the same setup on the other tLogRow component.

Complete Job Execution is shown below

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5 comments:


  1. Thanks for helping us understand this topic. you have written it in a way that makes it
    very simple to understand. Thanks you so much.

    click here

    ReplyDelete
  2. You article is good and value able information keep up the good work thanks.
    Look at this

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This post was very nice and useful thanks for sharing servicenow tutorial

    ReplyDelete
  5. This is great collection of shotguns at British shooting show.

    ReplyDelete