TomW Posted September 8, 2023 Share Posted September 8, 2023 I am trying to retrieve a list of requests that have been scheduled using the Hornbill API. The API that I am calling is the getScheduledRequests API and I am using the following PowerShell script: function Get_ScheduledRequests { <# .SYNOPSIS Attempt to get a list of scheduled requests #> #region : VARIABLES [String]$Method = 'getScheduledRequests' [String]$Parameter = @() [String]$RestMethod = 'post' [String]$Service = 'apps/com.hornbill.servicemanager/ScheduledRequests' [Int]$RowStart = 1 [Int]$RowCount = 2147483647 #this field is int32 where the maximum value is 2147483647 #endregion @ VARIABLES #region : Assign API parameters $Parameter = @( #"<searchFilter>h_status=status.open</searchFilter>" #"<deskId></deskId>" "<rowStart>$RowStart</rowStart>" "<rowLimit>$RowCount</rowLimit>" ) #endregion : Assign API parameters [String]$ParameterIsCMInstalled = 'true' [String]$ParameterLanguage = "en-GB" Try { $InvokeSmXmlMcParam = @{ Method = $Method Parameter = $Parameter RestMethod = $RestMethod Service = $Service ErrorAction = 'Stop' } echo($InvokeSmXmlMcParam) $ApiResponse = Invoke-HbRestMethod @InvokeSmXmlMcParam $retVal = $ApiResponse } #Try Catch { $retVal = -1 Write-Error $_.Exception.Message } #catch return $retVal } The value returned is as follows: outcome totalRecordCount scheduledRequests ------- ---------------- ----------------- success 0 [] We have a lot of requests which have been scheduled so I am wondering if I am passing the wrong information to the API method. I know the rest of the code (not shown above) works fine as I use other Hornbill APIs to run and retrieve reports. If you could highlight any obvious mistakes I've made or point me in the right direction that would be a great help! Link to comment Share on other sites More sharing options...
Steve Giller Posted September 8, 2023 Share Posted September 8, 2023 Note: Moved to a more appropriate forum. Link to comment Share on other sites More sharing options...
TomW Posted September 25, 2023 Author Share Posted September 25, 2023 I tried calling a similar API request but this time calling the "read" API method within the "SearchHistory" web service as follows: function Get_SearchHistory { <# .SYNOPSIS Attempt to get a list of scheduled requests #> #region : VARIABLES [String]$Method = "read" [String]$Parameter = @() [String]$RestMethod = "post" [String]$Service = "apps/com.hornbill.servicemanager/SearchHistory" [Int]$deskID = 5 #this field is int32 where the maximum value is 2147483647 [Int]$RowStart = 1 [Int]$RowCount = 20 #this field is int32 where the maximum value is 2147483647 #endregion @ VARIABLES #region : Assign API parameters $Parameter = @( "<searchTerm></searchTerm>" ) Write-Host($RowStart) #endregion : Assign API parameters [String]$ParameterIsCMInstalled = "true" [String]$ParameterLanguage = "en-GB" Try { $InvokeSmXmlMcParam = @{ Method = $Method Parameter = $Parameter RestMethod = $RestMethod Service = $Service ErrorAction = 'Stop' } #Write-Host($InvokeSmXmlMcParam) $ApiResponse = Invoke-HbRestMethod @InvokeSmXmlMcParam $retVal = $ApiResponse } #Try Catch { $retVal = -1 Write-Error $_.Exception.Message } #catch return $retVal } The output, particularly the JSON, was as follows: queryExecJSON ------------- ["finance","mam","morning","etarmis"] Unlike the "getScheduledRequests" API method this one seems to work. I suspect the the "getScheduledRequests" API method is broken. It shows as successful but returns no data even though we have numerous scheduled requests. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now