This documentation is for an outdated version: 14.6.8. The current version is 14.6.17 - get the documentation here.

Flow action request

The request action carries out a HTTP or HTTPS request to load content from remote sources.

Syntax

  • content="..." to set the id for a request (optional, default is main)
  • url="..." to set the request URL (required)
  • method="GET|POST|..."to set the request method (optional, default is GET)

The request element may contain any request options.

Examples:

<request content="main" url="http://example.com">
  <timeout request="1" connect="2" />
  <header name="X-A" value="A" />
  <query name="y" value="b" />
  <post name="x" value="a" />
  <upload name="fieldName" filename="path_to_file.txt" size="123" type="text/plain" src="fit://request/upload/myFile" />
</request>
<request content="weather" url="http://example.com/weather" />

Usage

The response body will be written into fit://request/content/<ID>. Additional information about the response, such as headers and status code can be found in fit://request/content/<ID>/response.

The main request (with content="main") receives a special treatment. See default-request action for more information. Usually you should use default-request to obtain the main content.

If you want to request more than one content, you should use the requests action that is able to execute requests in parallel. The syntax is the same. Thus wrapping a <request> with a <requests> parent element is equivalent.

All request options set in conf/sources.xml file that match the requested domain and path will also be applied to your request. However, options in the action have precedence over those from conf/sources.xml.

Be careful with selection values for the name attributes in input elements (<input name="" ... />) in your HTML documents. PHP automatically replaces many signs to underscores (_), so it can lead to unexpected field names in your backend systems. In some cases PHP removes even the fields completely from request.

Examples:

<input name="test.abc" /> <!-- Result: "test_abc" -->
<input name="test.abc[]" /> <!-- Result: "test_abc[]" -->
<input name="test[abc].xyz" type="input" /> <!-- Result: "test[abc]" -->
<input name="test[abc].xyz" type="file" /> <!-- Result: this field will be completely removed -->