Skip to content

Instantly share code, notes, and snippets.

@eahrold
Last active August 29, 2015 14:11
Show Gist options
  • Save eahrold/6148322036614bcd9b07 to your computer and use it in GitHub Desktop.
Save eahrold/6148322036614bcd9b07 to your computer and use it in GitHub Desktop.
Test POST to your JDS
#/usr/bin/python
''' if you don't have the requests module installed you'll need to do that
with either pip or easy_install'''
import os,requests
''' Setup server and auth data. This is the name of your JSS,
NOT the webdav share of the JDS. The JSS actually distributes the
data you upload to it across the JDS shares.
'''
server = 'https://pretendco.jamfcloud.com'
username = 'myusername'
password = 'mypassword'
# strip off trailing "/" characters from server
server = server.rstrip('/')
# construct the session elements
filename = '/tmp/test.txt'
resource = open(filename, 'a+rb')
basefname = os.path.basename(filename)
headers = {'DESTINATION': '1', 'OBJECT_ID': str(-1), 'FILE_TYPE':0, 'FILE_NAME': basefname}
jds_upload_url = '%s/dbfileupload' % server
# create the session and post
session = requests.session()
session.auth = (username, password)
response = session.post(url=jds_upload_url, data=resource, headers=headers)
# clean up, close our FD
resource.close()
# print out the response
print "Response: %s\n" % response
print "Response Text: %s\n" % response.text
print "Response Headers: %s\n" % response.headers
print "Response History: %s\n" % response.history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment