Solved!
the URL is incorrect:
$apiURL = “https://ssaddress/ss/winauthwebservices/api/v1/secrets/$SecretId”
it should be:
$apiURL = “https://ssaddress/ss/api/v1/secrets/$SecretId”