Forum Discussion

Skeer's avatar
Skeer
Icon for Neophyte rankNeophyte
4 months ago

SDTing via API, one source work the other does not

So I've been working on an LM/Jira JSM integration lately.. the native functions did not work for us. And to be quite honest I cannot remember the details but suffice to say that I have a working Custom HTTP Delivery with three URLs for Active, ACK, and Clear alert functions.

Now the goal is an automation action on the Jira side to SDT a specific host. So I began by building and testing the call in Postman. Works like a champ.. I can add a DeviceSDT, with a comment using the deviceDisplayName for a period of 1 hour. Exactly what I want in Jira.

Build out the automation rule, it's a manual action with no user input. It should add a DeviceSDT to a variable {{deviceHostname}} with variables that are defining epoch time in MS for {{now}}, and an endDateTime of 1 hour.. again in epoch MS format.

I test it and nothing happens. Jira reports back an HTTP400. Odd.. so I run the same thing in Postman and it works. Ok remove the variables and replace them with static content, mirroring exactly whats in the Postman payload. Still, 400 error. 

Stumble across https://webhook.site (which is fabulous for this sort of thing BTW) Nope.. the call/payload from Jira is 100% identical to Postman. Same Bearer token, and mostly the same headers; content-type, accept-encoding, Accept, Connection and User-Agent. Postman does add a couple that are unique to it but I have not found any doc on what (if any) headers other than Authorization, are required for this SDT call.

So does anyone here have any suggestions? I do have a case open with LM support as well as Atlassian.

Thanks!

39 Replies

  • Hmm so v3 must also have some deviations in the syntax or formatting. Postman complains now after adding 'X-Version:3' with "errorMessage":"invalid type", "errorCode":1400

    • Stuart_Weenig's avatar
      Stuart_Weenig
      Icon for Mastermind rankMastermind

      Do your headers include a content-type header with application/json as the value?

  • I see a slightly different body in the v3 swagger examples. More testing.

  • Well, looks like you can no longer add a Device-specific SDT using V3, am I understanding that correctly? There's no 'Device' type anymore, and no fields to specify deviceDisplayName or deviceID.

    • Mike_Moniz's avatar
      Mike_Moniz
      Icon for Professor rankProfessor

      One trick that can help is that the portal itself uses the API. So you can set in SDT in the portal and watch the Networking tab of the Browser's developer tools to see the request and parameters. Like here is what I got when doing a 1 hr SDT on a device:

      {"deviceId":100,"type":"ResourceSDT","sdtType":"oneTime","startDateTime":1715093520000,"endDateTime":1715097120000,"timezone":"America/New_York","comment":"test"}

      P.S. The portal does sometimes use undocumented or functions that are not in the API. But most day-to-day stuff uses the same API.

      • Skeer's avatar
        Skeer
        Icon for Neophyte rankNeophyte

        Ha! Yeah I'd think it'd be important to include 'deviceId' in the swagger docs. My main skill set is not developer related so I rarely think about dev tools like that. Good call.

  • So ResourceSDT, I don't see an obvious next field to define which resource. 

    Looks like, perhaps, you can ignore the epoch time stuff and maybe specify a duration too?

  • It's working from Postman now.. resourceSDT and deviceId were the key. Also you can leave out the epoch fields and just use duration, it worked for me just now.

  • I was kinda hoping someone would offer a suggestion on who to give the Solution to ;)

    Also wanted to come back.. I've encountered another small thing that directly related to this. I've added the call I mentioned earlier that gets the deviceId value from ../rest/device/devices?filter=name:"{{var1}}*" except Jira claims :Illegal character in query at index 72

    The URL sent is: https://xxxxxx.logicmonitor.com/santaba/rest/device/devices?filter=name~"new-hostaa01.xxxx.net*"

    I've sanitized but maintained the number of characters.. Its complaining about the tilde, I tried replacing it with the colon but it generated the same error on the same character.

    Exact same call from Postman (like earlier) works. X-Version:3 header in both.

      • Skeer's avatar
        Skeer
        Icon for Neophyte rankNeophyte

        Taking this suggestion I replaced the :" with %3A%22 and the trailing " with another %22.

        This time the call looks like it might have been sent. I need to add a couple more audit log actions. But it's a solid maybe!

    • Stuart_Weenig's avatar
      Stuart_Weenig
      Icon for Mastermind rankMastermind

      endoceURIComponent() in javascript. Do that to your query parameter values.

      • Stuart_Weenig's avatar
        Stuart_Weenig
        Icon for Mastermind rankMastermind

        encodeURIComponent()

        We have AI that can paint the mona lisa, but it can't detect spelling errors?

  • As a test I removed the dbl-quotes, 'Invalid filter'.. same as what Postman says if I do the same.