Friday, December 6, 2024

Accessing LM with a bearer token through Postman

I'm a day late on this one, but at least it's good info:

Original content is here for now.
  1. Download and install Postman, or use http://postman.com
  2. Launch Postman and create a new collection that will be used for all LogicMonitor API requests:
    1. In Postman, click Import and paste https://www.logicmonitor.com/swagger-ui-master/api-v3/dist/swagger.json. This should start the import process. 
    2. Before clicking the import button, click the gear to view import settings. 
    3. Make sure "Always inherit authentication" is checked on.
  3. Configure Authentication:
    1. Go to the collection root and select the auth tab.
    2. Change the auth type to "Bearer Token" and put {{bearer}} as the token.
    3. Go to the scripts tab and add this to the pre-request script:
      pm.request.headers.add({key: 'X-Version', value: '3'})
    4. Save the collection.
  4. Create a new environment with the following variables. You just need one for the bearer token. You should set the type to 'secret' for sensitive credentials.
    1. url – https://<portalname>.logicmonitor.com/santaba/rest
      1. If you want to work with the LM Ingestion API, duplicate this environment and change the url to 'https://<portalname>.logicmonitor.com/rest' (without "santaba")
    2. bearer – secret – For the current value, be sure to prepend the token with "bearer " (with space)
And that should do it. You should be able to open any request already defined in the collection you imported and run it.

No comments:

Post a Comment