G2A Many GEOs
SHARE
TWEET

RingCentral Send Fax - Multipart Test (Bad Request)

Mannyxpress Nov 27th, 2019 (edited) 8 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Pack the JSON DATA
  2.  
  3. $todestination = [pscustomobject]@()
  4. $todestination += @{
  5.     phoneNumber = "+14435551212"
  6.     name = "Test Recipient"
  7. }
  8.  
  9. ### CONVERT FILE CONTENT TO BASE64 STRING
  10. $FilePath = "$($env:TEMP)\TestFax.PDF"
  11. $objFile = Get-ItemProperty -Path $FilePath
  12. $FileData = [Convert]::ToBase64String([IO.File]::ReadAllBytes($FilePath))
  13.  
  14. # Create Attachment Param
  15. $attachmentdata = "data:application/pdf;name=$((Get-ItemProperty -Path $FilePath).Name);base64,$($FileData)"
  16.  
  17. $RingCentralSendFaxJson = [pscustomobject]@{}
  18. Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name attachment -Value $attachmentdata
  19. Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name to -Value $todestination
  20. Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name faxResolution -Value "High"
  21. Add-Member -InputObject $RingCentralSendFaxJson -MemberType NoteProperty -Name coverPageText -Value "Have cover page text"
  22.  
  23. $RingCentralSendFaxJson = $RingCentralSendFaxJson | ConvertTo-Json
  24.  
  25. $accountId = "~"
  26. $extensionId = "~"
  27.        
  28. #Send the text message
  29. $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
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top