IBM Cloud Certificate Manager: Unable to retrieve list of certificates using the curl command

225 views Asked by At

I'm following the cert manager documentation but cannot seem to successfully run the curl commands. The doc gives an example regarding how to retrieve a list of certs:

curl -H "Authorization: Bearer IAM-token" https://api-endpoint/api/v2/URLencodedCRN-basedinstanceId/certificates/

I have substituted my IAM-token, my api-endpoint as eu-gb.certificate-manager.cloud.ibm.com and my CRN but I get the following error:

Cannot GET /api/v2/mycrn/certificates/

Any idea what I could be doing wrong here? Thanks.

1

There are 1 answers

6
Idan Adar On BEST ANSWER

You can use the service's Swagger UI to test a request and see how the cURL request should look like.

In all likelihood you did not URL encode the instance CRN.

Swagger UI: https://eu-gb.certificate-manager.cloud.ibm.com/docs/#/Certificates_Repository/list

Service ID (decoded):

crn:v1:bluemix:public:cloudcerts:eu-gb:a/eff54442111ad670345651f3d69d6ed:1f1ac62e-85ee-4da9-8e3a-f30a80918843::

Service ID (encoded):

crn%3Av1%3Abluemix%3Apublic%3Acloudcerts%3Aeu-gb%3Aa%2Feff54442111ad670345651f3d69d6ed%3A1f1ac62e-85ee-4da9-8e3a-f30a80918843%3A%3A

Full request:

curl -X GET "https://eu-gb.certificate-manager.cloud.ibm.com/api/v3/crn%3Av1%3Abluemix%3Apublic%3Acloudcerts%3Aeu-gb%3Aa%2Feff54442111ad670345651f3d69d6ed%3A1f1ac62e-85ee-4da9-8e3a-f30a80918843%3A%3A/certificates" -H "accept: application/json" -H "Authorization: Bearer [IAM TOKEN]"

You should also use v3 instead of v2 as this API endpoint version is deprecated.