User Tools

Site Tools


transformations:webrequest

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
transformations:webrequest [2019/10/31 11:17] – [Cookies] dmitrytransformations:webrequest [2021/07/19 00:25] craigt
Line 1: Line 1:
-===== Web Request =====+{{ transformations:WebRequestAction.png}} 
 +====== WEB REQUEST ====== 
 +Category: Workflow / External\\
  
-Category: Workflow / External +\\  
- +=====Description===== 
-Sends a single HTTP request to a web server and receives a response. Intended for interactions with REST APIs, cloud applications and websites. Requires a configured Web Location connector.+This action sends a single HTTP request to a web server and receives a response. configured [[connectors:weblocation|Web Location]] connector is required.
  
 Supports all HTTP methods - GET, POST, PUT, DELETE, HEAD, OPTIONS, CONNECT, TRACE, PATCH. Supports all HTTP methods - GET, POST, PUT, DELETE, HEAD, OPTIONS, CONNECT, TRACE, PATCH.
Line 9: Line 11:
 To simplify development and debugging, the action has a preview pane that shows the raw HTTP request that would be sent as well as a response preview. To simplify development and debugging, the action has a preview pane that shows the raw HTTP request that would be sent as well as a response preview.
  
-====Path==== +\\  
-The URL path is appended to the endpoint URL specified in Web Location connector. EasyMorph parameters can be inserted into the path using curly bracesif needed. Alternatively, the entire path can be specified with a parameter.+=====Use cases===== 
 +This action is intended for interactions with REST APIs, cloud applications, and websites. 
 + 
 +\\  
 +=====Action settings===== 
 +^ Setting  ^ Description 
 +|Connector/Base URL<sup>*</sup>|Select or create a Web Location connector, or enter the base URL for the request.  Select between "Connector" and\\ "Base URL" using the selector to the //left// of the input field.| 
 +|Request method|Select the request method.  Options:  //GET//, //HEAD//, //POST//, //PUT//, //DELETE//, //CONNECT//, //OPTIONS//, //TRACE//,\\ and //PATCH//.| 
 +|Path<sup>*</sup>|See "Path setting", below.| 
 +|Add URL parameters<sup>*</sup>|Check to insert parameters into the URL.  See "URL parameters", below, for details.| 
 +|Body<sup>*</sup>|See "Request Body settings", below.| 
 +|Headers<sup>*</sup>|See "Request Headers settings", below.| 
 +|Response<sup>*</sup>|See "Response settings", below.| 
 +<sup>*</sup> Setting can be specified using a [[:parameters|parameter]].\\ 
 +\\  
 +====Path setting==== 
 +The URL path is appended to the endpoint URL specified in the Web Location connector. EasyMorph parameters can be inserted into the path using curly braces if needed. Alternatively, the entire path can be specified with a parameter.
  
-Examples:+**Examples:**
 ^ Web Location endpoint ^ Web Request path ^ Actual HTTP request URL ^ Notes ^ ^ Web Location endpoint ^ Web Request path ^ Actual HTTP request URL ^ Notes ^
 | %%https://example.com/api/v3%%  | products  | %%https://example.com/api/v3/products%% | | | %%https://example.com/api/v3%%  | products  | %%https://example.com/api/v3/products%% | |
 | %%https://example.com/api/v3%%  | product/123  | %%https://example.com/api/v3/product/123%% | | | %%https://example.com/api/v3%%  | product/123  | %%https://example.com/api/v3/product/123%% | |
 | %%https://example.com/api/v3%%  | product/{ProductID}  | %%https://example.com/api/v3/product/123%% |Assuming {Product ID} = 123 | | %%https://example.com/api/v3%%  | product/{ProductID}  | %%https://example.com/api/v3/product/123%% |Assuming {Product ID} = 123 |
 +\\ 
 ====URL parameters==== ====URL parameters====
-URL parameters can be specified as name-value pairs. They will be encoded and appended as URL query. Value can be omitted, in needed. In this case, only the name will be appended to the URL query.+URL parameters can be specified as name-value pairs. They will be encoded and appended as URL query. //Value// can be omitted, if needed. In this case, only the name will be appended to the URL query.
  
 +**Example:**
 ^ Web Location endpoint ^ Web Request path ^ Name ^ Value ^ Actual HTTP request URL ^  ^ Web Location endpoint ^ Web Request path ^ Name ^ Value ^ Actual HTTP request URL ^ 
 | %%https://example.com/api/v3%%  | orders  | year  | 2019  | %%https://example.com/api/v3/orders?year=2019%% | | %%https://example.com/api/v3%%  | orders  | year  | 2019  | %%https://example.com/api/v3/orders?year=2019%% |
  
 If a Web Location connector has permanent URL parameters specified they will be appended to all requests that are made using the connector. This can be used for scenarios where all requests should have an API key or secret specified. If a Web Location connector has permanent URL parameters specified they will be appended to all requests that are made using the connector. This can be used for scenarios where all requests should have an API key or secret specified.
-====Request body====+ 
 +\\  
 +====Request Body settings====
 The request body can be specified in one of the following ways: The request body can be specified in one of the following ways:
  
-===JSON===+__**JSON**__\\
 This body type is suitable for sending simple JSONs. The JSON object is constructed from a list of name-value pairs. Both name and value can be specified with a parameter. If the value itself is a JSON object/array it's inserted verbatim thus allow object nesting. This body type is suitable for sending simple JSONs. The JSON object is constructed from a list of name-value pairs. Both name and value can be specified with a parameter. If the value itself is a JSON object/array it's inserted verbatim thus allow object nesting.
  
 When this body type is selected header "Content-Type:application/json" is set automatically. When this body type is selected header "Content-Type:application/json" is set automatically.
  
-Example:+**Example:**
  
 ^ Name ^ Value ^ ^ Name ^ Value ^
Line 42: Line 63:
 |Tags    | ["ETL", "analytics", "dataprep", "automation"]| |Tags    | ["ETL", "analytics", "dataprep", "automation"]|
  
-Resulting request body (JSON):+**Resulting request body (JSON):**
  
 <code> <code>
Line 54: Line 75:
 </code> </code>
  
 +\\ 
 +__**Text**__\\
 +This body type specifies the body as a free-form text with parameters inserted if needed.
  
-===Text=== +\\  
-This body type specifies body as a free-form text with parameters inserted, if needed. +__**Form**__\\ 
- +This body type is equivalent to submitting a web form. Name-value pairs are encoded as if it was a web-form.
-===Form=== +
-This body type is equivalent to submitting a web-form. Name-value pairs are encoded as if it was a web-form.+
  
 Header Content-Type is automatically set to "application/x-www-form-urlencoded". Header Content-Type is automatically set to "application/x-www-form-urlencoded".
  
-Example:+**Example:**
 ^ Name ^ Value ^ ^ Name ^ Value ^
 |Country |CA | |Country |CA |
Line 69: Line 91:
 |Name    |EasyMorph  | |Name    |EasyMorph  |
 |Incorporated  |2014 | |Incorporated  |2014 |
- +\\  
-Resulting request body:+**Resulting request body:**
 <code> <code>
 Country=CA&Province=ON&Name=EasyMorph&Incorporated=2014 Country=CA&Province=ON&Name=EasyMorph&Incorporated=2014
 </code> </code>
  
-===File===+\\  
 +__**File**__\\
 The request body is read from the specified file and inserted verbatim. The request body is read from the specified file and inserted verbatim.
  
-====Request headers====+\\  
 +====Request Headers settings====
 Additional request headers can be specified. Header names and values can be specified either explicitly or using parameters. Additional request headers can be specified. Header names and values can be specified either explicitly or using parameters.
  
Line 84: Line 108:
  
 If a Web Location connector has permanent headers specified they will be added to all requests that are made using the connector. This can be used for scenarios where all requests should have an API key or secret. If a Web Location connector has permanent headers specified they will be added to all requests that are made using the connector. This can be used for scenarios where all requests should have an API key or secret.
-====Response==== 
  
-There are 3 modes how a response would be processed in the Web Request action:+\\  
 +====Response settings==== 
 +There are 3 modes for how a response would be processed in the Web Request action:
  
-===Fail if HTTP error, otherwise ignore=== +__**Fail if HTTP error, otherwise ignore**__\\ 
-In this case, if the response status is not an error (i.e. HTTP status codes 4xx or 5xx) then the response will be ignored. This is basically "fire-and-forget" mode that is intended for submitting data and updates to remote endpoints.+In this case, if the response status is not an error (i.e. HTTP status codes 4xx or 5xx) then the response will be ignored. This is basically "fire-and-forget" mode that is intended for submitting data and updates to remote endpoints.
  
-===Return response as the action result=== +__**Return response as the action result**__\\ 
-In this mode, the response (error or not) is always received and transformed into a 1-row dataset in EasyMorph. The column names in such dataset correspond to response body, response status, and response headers (one column per each header).+In this mode, the response (error or not) is always received and transformed into a 1-row dataset in EasyMorph. The column names in such dataset correspond to the response body, response status, and response headers (one column per header).
  
-===Fail if HTTP error, otherwise save response body into file=== +__**Fail if HTTP error, otherwise save response body into file**__\\ 
-In this case, if the response status is not an error (i.e. HTTP status codes 4xx or 5xx) then the response body (only body!) will be saved verbatim into the specified file.+In this case, if the response status is not an error (i.e. HTTP status codes 4xx or 5xx) then the response body (only the body!) will be saved verbatim into the specified file.
  
 +\\ 
 +=====Remarks=====
 ====Cookies==== ====Cookies====
 Currently, there is no way to set HTTP cookies explicitly in the Web Request action. Under the hood, all cookies that come with responses to web requests are automatically stored in a cookie container that exists only during project execution. Cookies from the container are automatically appended to outgoing requests made using the same Web Location connector. If a project workflow includes calls/iterations, the cookie container is passed to called/iterated modules or projects which in turn can add new cookies to it. This can be used for cookie-based web sessions. Currently, there is no way to set HTTP cookies explicitly in the Web Request action. Under the hood, all cookies that come with responses to web requests are automatically stored in a cookie container that exists only during project execution. Cookies from the container are automatically appended to outgoing requests made using the same Web Location connector. If a project workflow includes calls/iterations, the cookie container is passed to called/iterated modules or projects which in turn can add new cookies to it. This can be used for cookie-based web sessions.
  
-When project execution is finished, the cookie container is discarded. No cookies are stored in project or Web Location connector.+When project execution is finished, the cookie container is discarded. No cookies are stored in the project or Web Location connector
 + 
 +When developing workflows with web requests it may be necessary to re-run parts of workflows. In this case, it is recommended to always start from the Web Request actions that do authentication so that the session cookies can be set under the hood.
  
-When developing workflows with web requests it may be necessary to re-run parts of workflowsIn this case it is recommended to always start from the Web Request actions that do authentication so that the session cookies can be set under the hood.+\\  
 +=====Community examples===== 
 +  * [[https://community.easymorph.com/t//1205/3|Verifying address data with SmartyStreets API]] ([[https://community.easymorph.com/uploads/short-url/1xoQhm3AHmuMpKY7WkI9BL5jcLw.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Table 1//; Action position: //1//) 
 +  * [[https://community.easymorph.com/t//1269/4|Example: use of Web Request and Iterate Web Request with the Community forum API]] ([[https://community.easymorph.com/uploads/short-url/kJFnuALFUX72j3pqdxLHkuc0LVa.morph|Project]]; Module: //Main//; Group: //Tab 1//;\\ Table: //Recently active users//; Action position: //1//) 
 +  * [[https://community.easymorph.com/t//1800/4|Download multiple files from HTTPS and copy to folder, preserving file names]] ([[https://community.easymorph.com/uploads/short-url/pQyGPi01bpxaWBHR6LdGlGMyRbH.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Table 1//; Action position: //1//) 
 +  * [[https://community.easymorph.com/t//2637/1|How to send notifications to Microsoft Teams]] ([[https://community.easymorph.com/uploads/short-url/ptOHJUPlJb2GsDIfWJvzvG53OhR.morph|Project]]; Module: //Main//; Group: //Group 1//; Table: //Table 1//; Action position: //1//)
  
-====See also====+\\  
 +=====See also====
 +  * [[transformations:iteratewebrequest|Iterate Web Request]] 
 +  * [[connectors:weblocation|Connector "Web Location"]]
  
-* [[transformations:iteratewebrequest|Iterate Web Request]] 
transformations/webrequest.txt · Last modified: 2023/04/21 03:52 by dmitry

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki