3 Replies Latest reply on Sep 12, 2017 4:05 AM by florian1

    Has anyone had success creating a Request Offering from a web form?

    RyanB. Rookie

      We're trying to adjust the code in a web form (Public facing) that we used to create HEAT 9.6.2 tickets. We've upgraded to Ivanti Service Management and our developer is having trouble with the data field parameters. We have run into a roadblock when trying to get the Request Offering data fields' parameter when specifying them as web service parameters. We tried using the exact name of the Request Offering as the field name (Label), but received an error.

       

       

       

       

       

       

       

       

       


      If we're taking the wrong approach to this, the goal is to pass collected form data and free form text into a Request Offering.

        • 1. Re: Has anyone had success creating a Request Offering from a web form?
          DrizztLU Apprentice

          Hi RyanB,

           

          If I understood right, you try to get your form to create a Service Request (with its request offering parameters).

           

          I'm doing it with a .NET MVC website, I don't know much about other languages, but the user help has a really good section on web services.

           

          Ivanti - Web Services - User Help

           

          The "SubmitRequest" section has the proper example

           

          Once you added the ServiceReference:

          1. You have to connect prior to getting the SubscriptionID (There's a Connect method which returns an AuthSessionKey)

          2. You get the subscription (the item in the service catalog matching the name you passed)

          3. You build the list of parameters (request offering data)

          4. Submit the request (and profit )

           

           

          Best Regards,

          Dylan

          • 2. Re: Has anyone had success creating a Request Offering from a web form?
            Rookie

            Hi,

            I imagine you are creating using SOAP? From experience the key field values that you'll 'most likely' require are SvcReqTmplLink and SvcReqSubscLink in the SR Object, you'll need to expose both fields to capture the values.

             

            I hope that helps.

            Tim

            • 3. Re: Has anyone had success creating a Request Offering from a web form?
              florian1 Expert

              Hi Ryan,

               

              here's a simple Powershell example. You will just have to modify the variables to fit your needs:

              - Request offering name: English offering name (ensure the API user has at least submit rights!)

              - Request offering parameter fields & values: In my case, I only have 3 Picklists ("pl_CIActiveClients" is validated)

              - Tenant-specific settings (User, role etc.)

              -------------

              #region functions
              Function Remove-NullValues($str){
                  If ([string]::IsNullOrEmpty($str)){
                          return ""
                      } 
                      Else{
                          return $str
                      }
              }
              
              
              Function Initialize-WebServiceProxy{
                  If ($Script:proxy -eq $null){
                      # generate WS proxy
                      Try{
                          Write-Debug "Generating WS Proxy from $($tenantURL)."
                          $Script:proxy = New-WebServiceProxy -Uri $tenantURL -Class "proxy" -Namespace FRSHEATIntegration -ErrorAction Stop
                      }
                      Catch{
                         Write-Debug "Error while connecting: $_"
                         return $false
                      }
                  }
              }
              
              
              Function Invoke-Connect{
              
              
                  Initialize-WebServiceProxy
              
              
                  # receive session key
                  Try{
                      Write-Debug "Using method `"Connect`" to obtain Session Key."
                      $connectResponse = $proxy.Connect($HEATAPIuserName,$HEATAPIPassword,$HEATAPITenant,$HEATAPIRole)
                  }
                  Catch{
                      Write-Debug "Error: $_"
                      return $false
                  }
              
              
                  If ($connectResponse.connectionStatus -eq "Success"){
                      $Global:sessionKey = $connectResponse.sessionKey
                      Write-Debug "Session Key received: $($sessionKey)"
                      return $true
                  }
                  Else{
                      Write-Debug "$($_.connectionStatus): $($_.exceptionReason)"
                      return $false
                  }
              }
              
              
              Function Invoke-GetSubscriptionId{
                  Param (
                      [Parameter(Mandatory=$true)]
                      [string]$RequestOfferingName
                  )
              
              
                  Initialize-WebServiceProxy
                  
                  # obtain session key
                  If ([string]::IsNullOrEmpty($sessionKey)){
                      If (!(Invoke-Connect)){
                          return ""
                      }
                  }
              
              
                  [string]$subscriptionId = ""
              
              
                  #Write-Debug "Searching for Offering `"$RequestOfferingName`"..."
                  Try{
                      $result = $proxy.GetSubscriptionId($sessionKey,$HEATAPITenant,$RequestOfferingName)
                  }
                  Catch [System.Web.Services.Protocols.SOAPException]{
                      If ($_.Actor -eq "SessionExpired"){
                          Write-Debug "Session expired. Requesting new Session Key."
                          If (Invoke-Connect){
                              $result = $proxy.GetSubscriptionId($sessionKey,$HEATAPITenant,$RequestOfferingName)
                          } Else {return $false}
                      }
                      Else{
                          Write-Debug "$_"
                          return $subscriptionId
                      }
                  }
                  Catch{
                      Write-Debug "Error: $_"
                      return $subscriptionId
                  }
              
              
                  If ($result.status -eq "Success")
                  {
                      #Write-Debug "$($result.status): $($result.obj.BusinessObjectName) with RecID $($result.recId) was created or updated."
                      [string]$subscriptionId = $result.subscriptionId
                      return $subscriptionId
                  }
                  Else{
                      Write-Debug "$($result.status): $($result.exceptionReason)."
                      return ""
                  }    
              }
              
              
              Function Invoke-SubmitRequest{
                  Param (
                      [Parameter(Mandatory=$true)]
                      [string]$ParamListItems,
              
              
                      [Parameter(Mandatory=$true)]
                      [string]$SubscriptionId,
              
              
                      [Parameter(Mandatory=$true)]
                      [string]$LoginId
                  )
              
              
                  Initialize-WebServiceProxy
                  
                  # obtain session key
                  If ([string]::IsNullOrEmpty($sessionKey)){
                      If (!(Invoke-Connect)){
                          return ""
                      }
                  }
              
              
                  $ParamFields = ConvertFrom-Json $ParamListItems
                  $srparamListItems = New-Object 'System.Collections.Generic.List[FRSHEATIntegration.FRSHEATServiceReqParam]'
              
              
                  ForEach ($Field in $ParamFields.Fields){
                      $tempFieldProperties = @{}
                      Foreach ($memberType in ($Field | Get-Member -MemberType NoteProperty).Name) {
                          $tempFieldProperties.Add($memberType,$($Field.$memberType))
                      }
                      $tempFieldClass = New-Object FRSHEATIntegration.FRSHEATServiceReqParam -Property $tempFieldProperties
                      $srparamListItems.Add($tempFieldClass)
                  }
              
              
                  Try{
                      $srResponse = $proxy.SubmitRequest($sessionKey,$HEATAPITenant,$SubscriptionId,$srparamListItems.ToArray(), $LoginId);
                      return $srResponse
                  }
                  Catch [System.Web.Services.Protocols.SOAPException]{
                      If ($_.Actor -eq "SessionExpired"){
                          Write-Debug "Session expired. Requesting new Session Key."
                          If (Invoke-Connect){
                              $proxy.SubmitRequest($sessionKey,$HEATAPITenant,$SubscriptionId,$srparamListItems.ToArray(), $LoginId);
                          } Else {return $null}
                      }
                      Else{
                          Write-Debug "$_"
                          return $null
                      }
                  }
                  Catch{
                      Write-Debug "Error: $_"
                      return $null
                  }
                  
              }
              #endregion
              
              
              $Global:HEATAPITenantURL = "http://yourtenanturl"
              $Global:HEATAPITenant = "yourtenant"
              $Global:HEATAPIuserName = "HEATAdmin"
              $Global:HEATAPIPassword = "12345"
              $Global:HEATAPIRole = "Admin"
              $Global:HEATAPIUri = "/HEAT/ServiceAPI/FRSHEATIntegration.asmx"
              $Global:tenantURL = $($Global:HEATAPITenantURL+$Global:HEATAPIUri)
              
              
              $HEATSubcriptionRecID = Invoke-GetSubscriptionId -RequestOfferingName:"Disable computer"
              
              
              $ServiceReqParams = @"
              {"Fields":[
                  {"strName":"pl_RequestType","strValue":"Decommissioning"},
                  {"strName":"pl_DecommissionReason","strValue":"Decommissioning"},
                  {"strName":"pl_CIActiveClients","strValue":"DD77472F41CD4932933D8D0EEA2351CA"}
                  ]}
              "@    
              
              
              $SubmitResult = Invoke-SubmitRequest -ParamListItems:$ServiceReqParams -LoginId:$HEATRequestorLoginID -SubscriptionId:$HEATSubcriptionRecID
              $SRRecId = $SubmitResult.reqData.strRequestRecId
              
              1 of 1 people found this helpful