Python Fax – Query Submitted Faxes with FaxQuery2

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

This example shows you learn how to use the FaxQuery2 method to retrieve detailed information about submitted faxes with Python. The FaxQuery2 method provides more advanced querying options than FaxQuery (for more details, see Side-by-side Comparison of Web Service Methods).

The following Python fax snippet displays information for a number of submitted faxes:

A simple script to check the status of a few fax transmissions
using the InterFAX FaxQuery2 SOAP API call.
import osa
from datetime import  datetime

client =  osa.Client("")

print('Testing FaxQuery2...')
# Create the QueryForm and fill in the data to search by, leave the other fields empty

fq2 = client.types.FaxQuery2(deep=True)
query_form = fq2.QueryForm
query_form.Subject.Verb = 'Equals'
query_form.Subject.VerbData = ''
query_form.FaxNumber.Verb = 'Equals'
query_form.FaxNumber.VerbData = ''
query_form.DateFrom  =  datetime(2010,1,1)
query_form.DateTo  = datetime(2099,12,31)
query_form.UserID.Verb ='Equals'
query_form.UserID.VerbData = ''
query_form.ReplyAddress.Verb = 'Equals'
query_form.ReplyAddress.VerbData = ''
query_form.TransactionID.Verb = 'Equals'
query_form.TransactionID.VerbData = ''
query_form.ParentTransactionID.Verb ='Equals'
query_form.ParentTransactionID.VerbData =''
query_form.Status.Verb = 'Equals'
query_form.Status.VerbData =''
query_form.ShowHiddenTransactions = 'true'

query_control = fq2.QueryControl
query_control.OnlyParents = 'false'
query_control.NumOfResults = 999
query_control.StartingRecord = 0
query_control.ReturnItems = 'true'
query_control.ReturnStats = 'true'
query_control.OrderBy = 'UserID'
query_control.AscOrderDirection = 'true'
result = client.service.FaxQuery2(fq2)

result_code = result.ResultCode