Export a list of existing subscriptions

Not Yet Reviewed

Is there any way to export a list of all current subscriptions existing in my environment? 

0

Comments

9 comments
Date Votes

Please sign in to leave a comment.

  • I think the subscriptions API endpoint will probably do the trick: https://help.xmatters.com/xmapi/index.html#get-subscriptions

    0
  • I took a look at those different API calls but I can't seem to figure out how to pull the data in my environment. I have tried to do this through Windows Powershell but am really new to all of this. I see cURL, Python, and JavaScript code options on the righthand side, does anyone know which of these I should be using? Or will any of them work? 

    0
  • Hi Mark,

    Some people like testing out things via an application like Postman and look at how the data comes back. With PowerShell it really depends on what you want to use to invoke the API call. Some can call CURL from there so the CURL syntax applies but others use different Powershell commands to build the API call and payload.

    Try it outside of powershell first and see how it works, if you are having issues with your script you can provide it and we may be able to take a look along with any errors you are getting.

    Happy Friday!

    0
  • My company is currently using the older REAPI integration...am I still able to make API calls if we are not yet on the XMAPI integration (looking to upgrade in 2022). Our instance is "mycompany.na2.xmatters.com" so would "mycompany.na2.xmatters.com/api/xm/1" be the correct URL to call to? 

    0
  • Hi Mark,

    Yes you would call to "mycompany.na2.xmatters.com/api/xm/1" but then specify the endpoint you want to query. In your case you would want to call something like:

    "mycompany.na2.xmatters.com/api/xm/1/subscriptions" as a GET request to get all subscriptions in your environment.

    Note that this will require authentication to send also so try with your credentials or a user you created with the REST Web Service User permissions.

    Happy Tuesday!

    0
  • I added the "REST Web Service User" role to my account and attempted this call:

    Invoke-RestMethod -Credential "myusername https://mycompany.na2.xmatters.com/api/xm/1/subscriptions"

    which prompted a Powershell credential request (YES!!!) but I am getting an authentication error:

    "Invoke-RestMethod : The remote server returned an error: (401) Unauthorized."

    I also tried "myusername@mycompany.com" as the login, same result. 

    If I enter the same URL into a web browser I get the same credential request and cannot seem enter anything that allow me in.

    Is there any additional role that needs to be added in additional to "REST Web Service User"? 

    Thanks in advance for your continued support!

    0
  • I was able to get this working using a different user id we have set up specifically for API calls. A co-worker has some previous experience in this arena and got me up and running with that account and I was able to pull subscriptions and even filter by specific id. 

    Thank you for the continued support, I am rolling now!

    0
  • I have had some success with API calls through Powershell lately using a "ws_api" user account we created. I am looking to pull all subscriptions information through a few different ways: by owner, by shared subscriptions, and by subscription form. I have tried the following commands but they all retrieve the same 1 subscription that my "ws_api" user owns:

    Invoke-RestMethod -Credential ws_api https://wegmans.na2.xmatters.com/api/xm/1/subscriptions?owner?Mark?Albright

    Invoke-RestMethod -Credential ws_api https://wegmans.na2.xmatters.com/api/xm/1/subscriptions?shareWith?bmsteiner

    Invoke-RestMethod -Credential ws_api https://wegmans.na2.xmatters.com/api/xm/1/subscriptions?23ae4ad4-5882-4466-9a65-3f1d79d9c48c?subscribers

    Do you have any thought on what change I can make pull the data I am showing in the commands vs the 1 single subscription owned by "ws_api"? 

     

     

    0
  • I'm going to assume the URLs you are using have more = than ? that are coming across in your post (otherwise the syntax would be wrong, e.g. it would be /subscriptions?owner=username instead of /subscriptions?owner?Mark?Albright as it is showing).

    Have you verified that the account you are using (ws_api) has access to view the subscriptions you are trying for?

    0

Didn't find what you were looking for?

New post