I can’t tell you the cause when you tried to use it as Primary Storage since you didn’t provide the Nextcloud log output from that. But when you tried to use it as External Storage, the cause looks to be a slash / at the end of your endpoint name which created a weird URL that you likely don’t have permissions for.
Endpoint should just be a hostname (the 2nd field in the GUI).
Also, your Primary Storage config looks to be a copy of the example from the docs. I assume your real config has actual port, etc parameters from your S3 provider/platform, correct? That 8443 is just an example!