Unable to access Xmatters apis

448 Views Asked by At

I am trying to make a REST API call to know who is on duty. Every time I run this command I get 401 status saying, unauthorized user. I can login successfully using the Xmatters Web Interface. Here is the API call I am making

curl -H "Content-Type: application/json" --user username "https://xxx.hosted.xmatters.com/api/xm/1/groups/groupId/calendar"

Where am I going wrong?

2

There are 2 best solutions below

0
On

To access the API, ensure the user has (at least) the "Limited Group Supervisor" role. If you've never done this before, here is how:

  • As an admin and using the website, navigate to the Users screen using the link near the top of the site
  • Search for and select the user in question
  • Select the Roles tab for that user
  • Select the Roles text field and a list should appear
  • Select Limited Group Supervisor (or appropriate role)
  • Finally, click Save

Your curl command can be as simple as curl --user username "https://xxx.hosted.xmatters.com/api/xm/1/groups/groupId/calendar"

API Doc: https://help.xmatters.com/xmAPI/#get-who-is-on-duty

0
On

I don't know what's wrong with your command, maybe you missed the GET or you do not need the header.

But this here should work

curl --silent -X GET    -H:"Authorization:Basic dXNlcjpwYXNzd29yZAo=" --url "https://blabla.hosted.xmatters.com"

A base64 string can be generated like this:

echo user:password | base64
dXNlcjpwYXNzd29yZAo=

I would recommend a tool like DHC (Chrome Extension) to test your URLs. You can also generate curl commands.