Legacy Dev Forum Posts

 View Only

Sign Up

Outbound contact list failing through powershell

  • 1.  Outbound contact list failing through powershell

    Posted 06-05-2025 18:33

    tkrogh | 2025-02-18 15:51:31 UTC | #1

    Trying to upload contact list via Upload Contact Lists feature in powershell script. Looks like it's working, but no contacts are imported Get response:

    correlationId


    35517118-160f-45a4-b5d3-8cc97307a040

    Code below:

    $environment = "usw2.pure.cloud"; $id = Removed $secret = Removed $FilePath = '\Users\kroght\OneDrive - Cedars-Sinai Health System\Documents\genesys parse\pfs_selfpay.txt'

    $auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("${id}:${secret}")) $response = Invoke-WebRequest -Uri "https://login.${environment}/oauth/token" -Method POST -Body @{granttype='clientcredentials'} -Headers @{"Authorization"="Basic ${auth}"} $responseData = $response.content | ConvertFrom-Json

    Wrtie the Bearer token to a variable.

    $bearer = "Bearer " + $responseData.access_token

    write-host $bearer

    $ContactListID = REMOVED $URL = 'https://apps.usw2.pure.cloud/uploads/v2/contactlist'; $fileBytes = [System.IO.File]::ReadAllBytes($FilePath); $fileEnc = [System.Text.Encoding]::GetEncoding('UTF-8').GetString($fileBytes); $boundary = [System.Guid]::NewGuid().ToString(); $LF = "rn"; $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("authorization", $bearer) $bodyLines = ( "--$boundary", "Content-Disposition: form-data; name="file"; filename="temp.txt"", "id: $ContactListID", "fileType: contactlist", "contact-id-name: Contact ID", "Content-Type: application/octet-stream$LF", $fileEnc, "--$boundary--$LF" ) -join $LF

    Write-Host $headers Write-Host $bodyLines

    try{ Invoke-RestMethod -Uri $URL -Method Post -ContentType "multipart/form-data; boundary="$boundary"" -Headers $headers -Body $bodyLines

    } catch{

    Write-Host "Error Message:" $.Exception.Message Write-Host $.ErrorDetails.Message Write-Host $ContactListID.id "," $ContactListID

    }


    system | 2025-03-20 15:51:33 UTC | #2

    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: 31792