The challenge is to get a secure connection to the PI WebAPI for which I used the WifiClientSecure.h library. At the moment this library only supports basic authentication. So we have to change the authentication mode of the PI WebAPI to basic authentication in AF (screenshot below). When you make use of basic authentication you’ll have to define an AuthenticationID in the code to setup the connection with the PI webAPI.

The OSIsoftWebApi-library is responsible for writing the data to the PI Data Archive. When the function PutValue() (by the code above) is called, it will create a https-request to send the data to the PI Data Archive. After sending the request it is just waiting for a (succesfull) response.