FB_IotHttpRequest

This function block enables the PLC to send HTTP commands to the server that has been configured with the function block FB_IotHttpClient. To be able to process an HTTP response, the output bBusy of this function block must first return FALSE. Then the content payload, specific header fields or a JSON string can be extracted from the response.
Syntax
Definition:
FUNCTION_BLOCK FB_IotHttpRequest IMPLEMENTS ITcIotHttpResponse
VAR_INPUT
sContentType : STRING((ParameterList.cSizeOfHttpContentType-1)) :='text/html;charset=UTF-8';
eCompressionMode : E_IotHttpCompressionMode := 'E_IotHttpCompressionMode.NoCompression';
END_VAR
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
eErrorId : ETcIotHttpRequestError;
nStatusCode : UINT;
nContentSize : UDINT;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
sContentType | STRING | Content type of the request, e.g. the initial value "text/html; charset=UTF-8". |
eCompressionMode | E_IotHttpCompressionMode | Enumeration of the different compression modes. Further information is provided in the chapter Compression. The list can be found in the Appendix. |
Outputs
Name | Type | Description |
---|---|---|
bBusy | BOOL | This output remains TRUE until the function block has executed the command. |
bError | BOOL | Becomes TRUE as soon as an error situation occurs. |
eErrorId | ETcIotHttpRequestError | Enumeration of status code on transport level e.g. if a certificate validation has failed. The enumeration can be found in the Appendix. |
nStatusCode | UINT | HTTP status code send from the server within the response. |
nContentSize | UDINT | Size of the content payload. |
Methods
Name | Description |
---|---|
Reads the response from the HTTP server. | |
Reads the value from a specified header field. | |
Parses the server response as JSON object. | |
Sends a request to the server as JSON object. | |
Sends a HTTP command to the server. | |
Sends a request to the server as an XML object. |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4024.7 or higher | IPC or CX (x86, x64, ARM) | Tc3_IotBase |