
The Function Block HTTP_REQUEST creates a RAW query for the HTTP interface.
Important: The variable to be sent from the HTTP interface must have the data type RAW.
The URI is defined as a variable on the right side under Communication. If it starts with a /, the first / is removed. To make a request to the lowest directory, only the variable / can be defined.
Some web servers require the User-Agent header. Otherwise, the page will not load. This is not an error of Antcas Control, but a protection mechanism of the requested web browser. Use the Header input with the content:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
The input defines the transmission method as a string. This can be, for example, "GET", "POST", "PUT" or similar. If no method is defined, GET is chosen as the default.
The input defines the header Content-Type as a string. If the input is not defined, the entry will not be added to the header.
Defines additional header entries as a string. Multiple headers are separated by a line break. The header Content-Length is automatically defined and the header Content-Type is defined with the value at input Type.
The input defines the query as a string. The query is the value after the question mark and is usually used in GET requests.
http://server/uri?query
The structure of a query looks like this:
var1=wert1&var2=wert2&va...
To ensure that the values are transferred correctly, it is advisable to encode the individual values with the Function Block URL_ENCODE or QUERY_ENCODE, as the data may possibly be transmitted incompletely.
Note: Note the maximum length of a URL if larger amounts of data need to be transferred. If necessary, use the POST method and send the query as Content.
The input Content is similar to that of the input Query. However, the data is transferred after the header and larger amounts of data are supported. Depending on the application, the type of Content may not have a query method.
Note: Only UTF-8 compliant data is supported. When transferring binary data, it is recommended to encode it with the Function Block BASE64_ENCODE.
The input defines the timeout of the request as time in the format T#30s in seconds. It is recommended to use a high timeout. Small values can lead to requests not being executed completely. Due to the Keep-Alive procedure, it may take some time before the requests are processed normally again.
If the input is true, the value at output Request will be NULL.
If the input is true, this forces the generation of the output Request. This input has priority over the input DIS.
The output returns a string in JSON format. If it was disabled, the value NULL is returned. It is usually connected directly to the output variable of the interface.
The output returns the length of the input Content in bytes.
Returns the ID of the last generated query. This is helpful to verify the response with the Function Block HTTP_RESPONSE.