1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: |
""" Upload attachment This script creates a new case with a file attachment called machine.PNG. machine.PNG must be in the same directory as this script. How to use this script: 1. Set up the appropriate fbSettings.py (see https://developers.fogbugz.com/default.asp?W198 for more details) 2. Run the script from the command line using: > python uploadAttachment.py See https://developers.fogbugz.com/default.asp?W194 for more information on using the FogBugz XML API with Python. """ from fogbugz import FogBugz import fbSettings import os fb = FogBugz(fbSettings.URL, fbSettings.TOKEN) fileName = 'machine.PNG' fullPath = os.path.join(os.path.dirname(__file__), fileName) h = open(fullPath, 'rb') # use rb for reading binary files files = {} files[fileName] = h resp = fb.new(sTitle="new case from XML API with attachment", Files=files) h.close() |