Api: Fix cURL call to HTTPS server

cURL requires a copy of the certificates to validate HTTPS requests.
See the relevant comment for more info.

Also fix some minor namespace issues.