PostmanEcho

This part of the sample includes three HTTP commands (GET, POST, PUT) to communicate with Postman Echo, which is a testing service for REST clients. Additionally, there is also an example for a GET request with header authentification.

The Postman Echo API is especially for developers in order to test HTTP functionality and delivers even many more possibilities as are shown in our sample. For example different authentication methods can be tested with Postman Echo.

PROGRAM MAIN
VAR
    // trigger command execution for Postman-Echo samples
    bGet, bPost, bPut, bHeaderAuth : BOOL;

    fbHttpClientPostman            : FB_IotHttpClient :=(sHostName:='postman-echo.com',
                                     bKeepAlive:=TRUE, tConnectionTimeout:=T#10S);

    fbHttpGet                      : FB_TestHTTP_Get;
    fbHttpPost                     : FB_TestHTTP_Post;
    fbHttpPut                      : FB_TestHTTP_Put;
    fbHttpHeaderAuth               : FB_TestHTTP_HeaderAuth;
END_VAR
//init client parameters at startup
IF NOT fbHttpClientPostman.bConfigured THEN
    fbHttpClientPostman.nHostPort:= 80;
END_IF

IF fbHttpClientPostman.bConfigured THEN
    fbHttpGet(bSend:=bGet, fbClient:=fbHttpClientPostman);
    fbHttpPost(bSend:=bPost, fbClient:=fbHttpClientPostman);
    fbHttpPut(bSend:=bPut, fbClient:=fbHttpClientPostman);
    fbHttpHeaderAuth(bSend:=bHeaderAuth, fbClient:=fbHttpClientPostman);
END_IF

fbHttpClientPostman.Execute();