Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

ratna53_110276 avatar image
ratna53_110276 asked ·

Can we pass the user ID and password with curl to make an OpsCenter API call?

Hello Team,

Can we pass the user id and password to get the information using curl.

$ curl -u username:password http://<opscenterHost>:<port>/<cluster_name>/alert-rules

when I tried the above it's not working. Can you please suggest some option to pass the user id and password to get the output


Thanks,

Ratna kumar

opscenter
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered ·

@ratna53_110276 If authentication is enabled on OpsCenter, you will need to authenticate first to obtain a session token like this:

$ curl -X POST -d '{"username":"admin","password":"test"}' 'http://localhost:8888/login'
{"sessionid": "d6c5e198b9b5ffeab9fd8dea6fb012aa"}

You would then include the session ID in the HTTP header when you make API calls like this:

$ curl -H 'opscenter-session: d6c5e198b9b5ffeab9fd8dea6fb012aa' http://localhost:8888/cluster-configs

For more information, see the Authentication page of the OpsCenter API documentation. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

yukim avatar image
yukim answered ·

You first have to authenticate using /login URL like below:

curl -X POST -d '{"username":"admin","password":"test"}' 'http://opescenter:8888/login'

It will give you a session ID to use for the requests you want to make:

{"sessionid": "d6c5e198b9b5ffeab9fd8dea6fb012aa"}

Now, you can use this session ID in HTTP header to call any OpsCenter API:

curl -H 'opscenter-session: d6c5e198b9b5ffeab9fd8dea6fb012aa' http://<opscenterHost>:<port>/<cluster_name>/alert-rules

See the following URL.

https://docs.datastax.com/en/opscenter/6.7/api/docs/authentication.html#authentication

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.