# https://forums.developers.ringcentral.com/questions/9012/sending-a-fax-attachment-using-powershell.html $todestination = [pscustomobject]@() $todestination += @{ phoneNumber = "+14435551212" name = "Test Recipient" } ### CONVERT FILE CONTENT TO BASE64 STRING $FilePath = "$($env:TEMP)\TestFax.PDF" $objFile = Get-ItemProperty -Path $FilePath $FileData = [Convert]::ToBase64String([IO.File]::ReadAllBytes($FilePath)) $RingCentralSendFaxJson = [pscustomobject]@{} Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name to -Value $todestination Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name faxResolution -Value "High" $RingCentralSendFaxJson = $RingCentralSendFaxJson | ConvertTo-Json $LF = "`r`n"; $boundary = "Boundry_$([System.Guid]::NewGuid().ToString();)" # Need to package the message body in multipart/mixed format $RingCentralSendFax = ( "--$($boundary)", "Content-Type: application/json", "", $RingCentralSendFaxJson, "", "--$($boundary)", "Content-Disposition: form-data; name=""attachment""; filename=""$($objFile.Name)""", "Content-Transfer-Encoding: binary", "Content-Type: application/octet-stream", "", "$FileData", "", "--$($boundary)--" ) -join $LF $accountId = "~" $extensionId = "~" #Send the text message $sendresponse = Invoke-RestMethod -Uri "https://platform.devtest.ringcentral.com/restapi/v1.0/account/$($accountId)/extension/$($extensionId)/fax" -Method Post -ContentType "multipart/mixed; boundary=$($boundary)" -Body $RingCentralSendFax -Headers $accesstoken.Header