Updating DNIS to Call Routes (300 max limit?)

All,

I have 3.5k DID's I'd like to associate to a Call Route. When passing an array of 280 DID's, my script works well. When passing 300 DID's, it errors out stating 'Request body must not be null' which I know is incorrect.

How can I determine if there is a limit when using PUT /api/v2/architect/ivrs/{ivrId} ?
Has anyone else been successful of adding more than 300 DIDs to an existing call route?

The API's are not the best.

You have to add more DDIs in chunks, it mentions up to 100 at a time but I dropped down to 50 for my powershell script, calling GC.EXE tool, to work without issue.
You also have to ensure you pass any existing DDIs in the list. Basically, you build up the complete list in small chunks.
Also, make sure no duplicates, or a block add will fail and any subsequent calls from same build.

If you using Powershell, I created a list of all the DDIs I was adding (from a csv but any source will do) after ensuring no duplicates.

[System.Collections.ArrayList]$List = @()  # empty collection of type list, so can .Add

My loop through CSV added each entry, e.g. ($entry is my csv object and the NGN field was a DDI

    # append our DiD to the list for Assignment to Ivr object at end. Output to $null as .Add returns index position
    $List.Add($entry.NGN) > $null

After that, I read the EXISTING Ivr route (so handles existing DDIs) and put on front of my list

     gc.exe architect ivrs get $ivrId -p $ProfileName | Set-Variable -Name ivrResponse
     #Convert that string to Json, then into Powershell object to allow manipulation
     [PSObject] $ivrObj = $ivrResponse | ConvertFrom-Json 
 # Insert ant existing dnis numbers at front of our list for the first PUT call 
 #
 # look at how many added, to allow for variable already existing DiD against IVR - push to front of list
 $dnisCount = $ivrObj.dnis.Count
 $ivrObj.dnis.ForEach({ ($List.Insert(0,$_) > $null ) })
 #
 Write-Output "Existing entries count $($dnisCount)" 
 $dnisCount++                   # Add 1 to force at least one new entry to first IVR PUT

This gets to point of a complete list of DDIs you want on IVR, you then need to add in chunks, I did 50 at time, and added a 30sec delay between them to allow Genesys processing to actually do the work. I created function to add entries.

[System.Collections.ArrayList]$ListPlus100 = @()
 for ($row = 1; $row -lt $List.Count + 1; $row++) {
    # Build first list to include already allocated DiD numbers on the IVR Id - added 1 to count get it to add some new
    # We pushed existing Did's on front of list, so can build them up from start.
    if ($row -lt ($dnisCount)) {
        $ListPlus100.Add($List[$row - 1]) > $null
        continue        # loop back to keep adding until over existing count
    }
    if ($row % 50 -eq 0) {
        # Write-Output "Adding next NEW block"
        Add-did
    }

    $ListPlus100.Add($List[$row - 1]) > $null

 }
 # Final function call for remaining entries
 Add-did

My Function logic, I created log files of blocks just to check and have audit of script...

Function Add-did {
    $Global:cc++
     Write-Output "Function call for next block...$($ListPlus100.count)"
     
     gc.exe architect ivrs get $ivrId -p $ProfileName | Set-Variable -Name ivrResponse
     #Convert that string to Json, then into Powershell object to allow manipulation
     [PSObject] $ivrObj = $ivrResponse | ConvertFrom-Json 
     #
     Write-Output $ivrObj | convertto-json > "Get_$Global:cc.json"
     #
     # Now replace dnis object with working block
     $ivrObj.dnis = $ListPlus100.ToArray() # ToArray otherwise the dnis and List become pointer to same!
     Write-Output $ivrObj | convertto-json > "GetAdded_$Global:cc.json"

     Write-Output $ivrObj | ConvertTo-Json > "Put_$Global:cc.json"
     Write-Output "PUTting ivr object with all new DiDs appended to GC.."
     #
     $ivrObj | convertto-json | gc.exe architect ivrs update $ivrId -p $ProfileName 2>&1 | Set-Variable -Name ivrPutResponse
     if ($LASTEXITCODE -ne 0) {  
        $errorResponse = $ivrPutResponse | ConvertFrom-Json
        Write-Output "Had error with PUT, code $($errorResponse.code) and status $($errorResponse.status) and message: $($errorResponse.message) --skipping DDI $($entry.NGN)"
        exit  # Don't carry on if error on create, go to next entry
    }
     Write-Output "Awful API, Sleep 30 seconds between calls, still may get API timeout even though seems to do in background"
     Start-Sleep 30 
 }

I am relatively new to Powershell scripting so may be better ways to do this.

Shame Genesys not add Patch method to add individual/blocks of DDIs to an existing call route.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.