Legacy Dev Forum Posts

 View Only

Sign Up

Creating WebRTC Phone using API/PowerShell

  • 1.  Creating WebRTC Phone using API/PowerShell

    Posted 06-05-2025 18:30

    BradHand | 2024-03-12 18:08:00 UTC | #1

    I've been fighting with getting this working and it just keeps erroring out saying that "Field 'templateId' is required and cannot be empty."

    I found the below post, although old, and it has a fairly simple code that I've tried to emulate to no avail.

    https://developer.genesys.cloud/forum/t/required-fields-for-post-telephony-providers-edges-phones/2828/6?u=bradhand

    This post references the exact error and says that it was caused by lineBaseSettings being required but not in the JSON. I have this there but still cannot get it to work.

    Updating remote phone adress through API - Platform API - Genesys Cloud Developer Forum

    Here's what I have in the JSON Body. I've previously had a Name field under Lines but that's removed from this example:

    {
        "webRtcUser":  {
                           "id":  "ID Value"
                       },
        "lines":  [
                      {
                          "lineBaseSetting":  {
                                                  "id":  "ID Value"
                                              }
                      }
                  ],
        "site":  {
                     "id":  "ID Value"
                 },
        "name":  "Brad Hand - WebRTC",
        "phoneBaseSettings":  {
                                  "id":  "ID Value"
                              }
    }

    And here's the direct PowerShell code:

        $WebRTCPhone = @{
            name = "Brad Hand - WebRTC"
            phoneBaseSettings = @{
                id = "ID Value"
            }
            webRtcUser = @{
                id = "ID Value"
            }
            site = @{
                id = "ID Value"
            }
    
            lines = @(
                @{
                lineBaseSetting = @{
                    id = "ID Value"
                    }
                }
            )
        }
    
        $WebRTCPhone | ConvertTo-Json -depth 5

    BradHand | 2024-03-13 13:33:49 UTC | #2

    Just so this is documented.... I missed the 'S' in lineBaseSettings!! >.> Such a rookie move and I just couldn't see it yesterday. Sometimes walking away and coming back the next day really helps. Below is working PowerShell code:

        $WebRTCPhone = @{
            name = "Brad Hand - WebRTC"
            phoneBaseSettings = @{
                id = "ID Value"
            }
            webRtcUser = @{
                id = "ID Value"
            }
            site = @{
                id = "ID Value" 
            }
            lines = @( 
                @{ 
                name = "Line1"
                lineBaseSettings = @{
                    id = "ID Value"
                }
                }
            )
        }
    
        $WebRTCPhone | ConvertTo-Json -depth 3 | Out-File C:\Temp\WebRTCPhone.txt -force
    
        gc.exe telephony providers edges phones create -f C:\Temp\WebRTCPhone.txt

    system | 2024-04-12 13:34:26 UTC | #3

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


    This post was migrated from the old Developer Forum.

    ref: 25151