Forum Discussion

mray's avatar
Icon for LM Conqueror rankLM Conqueror
26 days ago

Accessing the LogicMonitor REST API with Postman and Bearer Token Authentication

This is a follow-up to the classic Kurt_Huffman post: Accessing the LogicMonitor REST API with Postman and LMv1 API Token Authentication | LogicMonitor - 5143 

That post is still a treasure trove of good discussion. Definitely check it out if you haven't already! While there is passing mention that you can use bearer token auth in Postman, I figured I'd write up a dedicated post. 

Creating a bearer token

With the addition of bearer tokens, we eliminate the need for a Base64 encoded HMAC signature – so we get rid of several steps for auth. No need for any pre-request script, yay!

See this page for generating and using bearer tokens in LogicMonitor:

We do have a section in the above page on using the bearer token with Postman, but I like setting up with environment variables for better reusability.

Postman setup with bearer tokens

  1. Download and install Postman, or use 
  2. Launch Postman and create a new collection that will be used for all LogicMonitor API requests. 
  3. Create a new environment with the following variable. You just need one for the bearer token. You should set the type to 'secret' for sensitive credentials.
    • url – https://<portalname>
      • If you want to work with the LM Ingestion API, duplicate this environment and change the url to 'https://<portalname>' (without "santaba")
    • bearer – secret – For the current value, be sure to prepend the token with "bearer " (with space)
    • Should look like this: bearer lmb_xxx
  4. Create a request within the collection. A sample request is shown below with the necessary parameters configured.
    1. Set the environment for the request (from step 3)
    2. Set the HTTP method for the request
    3. Use {{url}} to pull the base URL from the environment variable. Add the resource path and any request parameters your API request may require.
    4. Add the following headers:
      • Authorization: {{bearer}}
      • X-version: 3 (for latest LM API version)
      • POST, PUT, and PATCH requests only: if your request includes JSON data, be sure to select the Body tab and select raw JSON

2 Replies

  • Appreciate it!!

    I haven't coded since college really...(we won't get into how long that's been) and there are a lot of things that have changed and some of it just isn't intuitive to me at this point. Anything that makes learning simpler is always welcome. Thank you!