Menu

Addressing Object's Activity (REST API)

2023-12-05
2023-12-05
  • Bogdan Khramkov

    Bogdan Khramkov - 2023-12-05

    Can't find the info how to get object creation date and actually just all connected activities using API calls
    Thanks in advance for pushing to the correct direction.
    BR

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2023-12-05

    I'm not sure if this info can be queried by the API, but you'd be looking at CMDBChangeOp* ( https://demo.combodo.com/simple/pages/schema.php?c%5Bmenu%5D=DataModelMenu ) which you'd need to query.

    Alternatively, create an API extension to do so.

     
    👍
    1
    • Bogdan Khramkov

      Bogdan Khramkov - 2023-12-05

      Hi Jeffrey,
      Yes. You're absolutely correct.
      I do the needed calls via Powershell. For this particular case it looks like:

      Function Get-iTopObjectCreationDate {
          param(
              $objclass,
              $servername,
              $serverid
      
          )
          if ($serverid -eq $null){
              write-host "Getting ServerId for $servername"
              $serverid = @()
              $serverid += (Get-iTopObjectByName -Class $objclass -name $servername -fields 'name,id').id
              if ($serverid.count -ne 1){
                  return "Number of servers in $servername in iTop is $($serverid.count)"
      
              }
          }
      
          $fields = 'date,userinfo'
          $data = @{
      
              operation= "core/get"
              class = "CMDBChangeOpCreate"
              key= @{
                  objkey= $serverid
                  objclass= $objclass
              }
              output_fields= $fields
          }
          $json = ConvertTo-Json $data
      
      
          return (Execute-iTopRestMethod -json $json)
      }
      

      Thanks a lot for You response! Have a great day!

       
      👍
      1

      Last edit: Bogdan Khramkov 2023-12-05

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.