EzzyBills User Guide

Rest API Examples using Python

Below is an API example using Python:

import requests
import json
from time import sleep

# Set up variables
url = 'https://app.ezzydoc.com/EzzyService.svc/Rest'
api_key = {'APIKey': '#INSERT API KEY#'}
payload = {'user': '#INSERT USER NAME#',
           'pwd': '#INSERT PASSWORD#',
           'APIKey': '#INSERT API KEY#'}

# Log in to EzzyBills
r = requests.get(url + '/Login', params=payload)

# Upload an invoice to EzzyBills
with open('taxinvoice.pdf', 'rb') as img_file:
    img_name = 'taxinvoice.pdf'
    data = img_file.read()
    b = bytearray(data)
    li = []
    for i in b:
        li.append(i)
    raw_data = {"PictureName": "taxinvoice.pdf", "PictureStream": li}
    json_data = json.dumps(raw_data)
    r2 = requests.post("https://app.ezzydoc.com/EzzyService.svc/Rest/uploadInvoiceImage",
                       data=json_data,
                       cookies=r.cookies,
                       params=api_key,
                       headers={'Content-Type': 'application/json'})
    invoiceID = str(r2.json().get("invoice_id"))

# Wait until invoice has been processed
while True:
    r4 = requests.get(url + '/workflowStatus?invoiceid=' + invoiceID,
                      cookies=r.cookies,
                      params=api_key)
    completeBool = str(r4.json().get("complete"))
    if completeBool == "True":
        break
    sleep(1)

# Get invoice total
r5 = requests.get(url + '/getInvoiceHeaderBlocks?invoiceid=' + invoiceID,
                  cookies=r.cookies,
                  params=api_key)
invoiceTotal = str(r5.json().get("invoiceForm").get("invoiceTotal"))
print("Invoice total is: $" + str(invoiceTotal))
Sections of Article