# Pack the JSON DATA $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)) # Create Attachment Param $attachmentdata = "data:application/pdf;name=$((Get-ItemProperty -Path $FilePath).Name);base64,$($FileData)" $RingCentralSendFaxJson = [pscustomobject]@{} Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name attachment -Value $attachmentdata Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name to -Value $todestination Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name faxResolution -Value "High" Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name coverPageText -Value "Have cover page text" $RingCentralSendFaxJson = $RingCentralSendFaxJson | ConvertTo-Json $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/form-data" -Body $RingCentralSendFaxJson -Headers $accesstoken.Header