PLANNED MAINTENANCE

Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


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.