Your header needs to include an authcode
Your header needs to include an authcode
https://api.commvault.com has much more verbose documentation and contains the CURL syntax in the examples. For authentication: https://api.commvault.com/#96595921-4cc1-4f2b-ab87-c3ec20c02f68
curl --location --request POST 'http://WebConsoleHostName/webconsole/api/Login' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"password": "<Base64 Encoded Password>",
"username": "<UserName>"
}'
Once you have the authentication token you can include it in the header like @chrisknows mentioned - in this example to get all clients
curl --location --request GET 'http://WebConsoleHostName/webconsole/api/Client?hiddenclients=true' \ --header 'Accept: application/json' \ --header 'Authtoken: QSDK token would be auto set after POST Login is called.'
Thanks @Damian Andre for the clarification.
So, if I understand correctly then are
“http://WebConsoleHostName/webconsole/api/Client?hiddenclients=true”
and
https://<webserver>/webconsole/api/v4/Servers?showOnlyInfrastructureMachines=1' same?
If not then I need to use the latter one. Can you confirm if the way of invocation is same for both of them?
No, that’s not what he is saying, the latter code sample was just an example that highlights that
All api requests have to include an auth code in the header.
That is why you are getting a 401 error, because you are not telling the webserver who you are.
So the first step in any api request is that you first authenticate/login to get an authcode.
Once you have an authcode, you can then submit whatever api request you want.
Please read this carefully to get more details on the authentication process.
Got that, thanks @chrisknows
Will try that out