Python Fax – Retrieve Outbound Fax Image

 Download the Python samples fax API zip file.
 Download the Modified OSA files.

This Python fax example demonstrates how to retrieve the image of an outbound (previously-submitted) fax with the GetFaxImage method:

The Python fax snippet below retrieves an image of an outbound fax using GetFaxImage:


"""
A simple script to check the status of a few fax transmissions
using the InterFAX GetFaxImage SOAP API call.
"""
import osa
import base64
import sys

# helper function to save file data
def save_file(file_name, file_data):
    ext = ".pdf" if file_data.startswith(b"%PDF") else ".tif"
    print ("\tSaving " + file_name + ext)
    with open(file_name + ext, "wb") as f:
        f.write(file_data)

client = osa.Client("https://ws.interfax.net/dfs.asmx?WSDL")


print('Testing GetFaxImage...')

result = client.service.GetFaxImage(Username='', Password='', TransactionID=614416600)
if result.GetFaxImageResult == 0:
        save_file("image_file", result.Image)
print('   GetFaxImage returned with code {0}'.format(result.GetFaxImageResult))