Post

TwinCAT TIA
Network REST Client ActiveClients One client

ns=2;s=DEPRAG Smart/Network/HTTP/REST/ActiveClients/0/Post

Sends a POST command to a URL.

Parameters:

    Content
    Content of the data passed in the HTTP command.

Returns:

    Post
    A variable of type OpcMethodReturnValueHttpResultWithStringContent. The Result property contains the command-specific return values.
      Result
      A variable of type HttpResultWithStringContent.
        Success
        Indicates whether the HTTP command was successfully fired.

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bHttpPost
    A boolean variable that can be used to trigger the execution of the Post command.
    OutputDataHttpPost
    An instance of ST_HttpResultWithStringContentOutputData structure in which the return value of the Post method is written.
    hrHttpPost
    This can be used to monitor the execution of the command. Error codes have the type HRESULT.
    fbHttpRest
    An instance of the "FB_HttpRest" function block supplied with the DEPRAG Smart library.
    sRequestUri
    A string(255) variable specifying the endpoint to which the command should be sent.
    sContent
    A string(255) variable representing the content to be sent.
    sClientId
    A String(255) variable that specifies the client that should execute the command.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
  bHttpPost   : BOOL;
  OutputDataHttpPost : ST_HttpResultWithStringContentOutputData;
  hrHttpPost   : HRESULT;
 
  fbHttpRest   : FB_HttpRest;
END_VAR

hrHttpPost := fbHttpRest.Post(
       bExecute   := bHttpPost, 
       ConnectionHandle:= depragSmartConnection.ConnectionHandle,
       sRequestUri  := '/testPost',
       sContent   := 'TestContent',
       sClientId   := '0',
       OutputData  => OutputDataHttpPost);
IF hrHttpPost <> S_FALSE THEN 
    bHttpPost := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".