Created
December 5, 2011 21:25
-
-
Save pedrocunha/1435430 to your computer and use it in GitHub Desktop.
Invoicexpress API - Python Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib, urllib | |
account_name = 'XXXX' | |
api_key = 'XXXXX' | |
url = account_name + '.invoicexpress.net:443' | |
endpoint = '/invoices.xml?api_key=' + api_key | |
headers = { | |
'Content-type' : 'application/xml; charset=utf-8', | |
'Accept' : 'text/plain' | |
} | |
params = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ | |
<invoice>\ | |
<date>19/10/2009</date>\ | |
<due_date>19/10/2009</due_date>\ | |
<client>\ | |
<name>Bruce Norris</name>\ | |
</client>\ | |
<items type=\"array\">\ | |
<item>\ | |
<name>Product 1</name>\ | |
<description>Cleaning product</description>\ | |
<unit_price>10.0</unit_price>\ | |
<quantity>1.0</quantity>\ | |
<unit>unit</unit>\ | |
</item>\ | |
</items>\ | |
</invoice>' | |
conn = httplib.HTTPSConnection(url) | |
conn.request("POST", endpoint, params, headers) | |
response = conn.getresponse() | |
print response.status, response.reason | |
data = response.read() | |
data | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment