ToBase64
Returns the raw response bytes encoded as Base64.
| myRestResponse.ToBase64():string
|
Returns
The response body as a Base64 string, or an empty string if there is no body.
Use this method for binary content such as PDF files or images.
Examples
Attach a downloaded file to an e-mail
| var pdf = $Rest.Create('https://api.example.com/')
.Request('invoices/{id}/pdf')
.AddUrlParameter('id', $Xml.Evaluate('InvoiceId'))
.Get()
.ToBase64();
$Messages.New($Xml.Evaluate('Customer/EMailAddress'), 'Your invoice', 'Please find your invoice attached.')
.Attach('Invoice.pdf', 'application/pdf', pdf)
.Send();
|