Skip to main content
Solved

Web Help Desk Mobile Devices sync python script through API's stopped working..


Forum|alt.badge.img+18
  • Esteemed Contributor
  • 831 replies

Just wondering how everyone using web help desk is getting the data from the mobile devices to sync.

We were using the API's to import the data and sync, using the sample python scripts in the JAMF SDK. However since the poodle SSL issue it looks like the python script has stopped working. Trying to now get around this issue:

Any ideas?
Gabe Shackney
Princeton Public Schools

Best answer by GabePPS

Nothing I know of changed, but looks like we found a work around with this xml:

#for Python 3.4 - Need to run this command to install requests library to python: pip install requests
import requests
import warnings
import time

warnings.filterwarnings('ignore')
print ("PPS XML Mobile Exporter for Casper Start")
#Open URL 
#Using the URL, UserName, Password, and turning off the certificate verification since the certificate is self signed
#always test url with browser first.
url = "https://casper:8443/JSSResource/mobiledevices"
r = requests.get(url, auth=('USERNAME', 'PASSWORD'),verify=False)
xml = r.content.decode(encoding='UTF-8')
#Open URL

#File
#Creates a connection to an output file and write out the XML data and close the file
file = open("mobile1.xml", 'w')
file.write(xml)
file.close()
#File

#Over Write File
#This needs to be done, so we have a new blank file, since the file is appended with every run through the loop
file = open("mobile2.xml", 'w')     
xml = ""
file.write(xml)
file.close()
#Over Write File

#Mobile 2 - A more detail report loop, to get more detail on each mobile device, as a short cut I loop through more times then we
#have mobile devices, since I only write a line out if the data is xml, if the id is not valid, an html file is returned and is ignored.
for count in range(1,20000):
    x = str(count)
    url = "https://casper:8443/JSSResource/mobiledevices/id/" + x + "/subset/General%26Location%26Purchasing"
    r = requests.get(url, auth=('USERNAME', 'PASSWORD'),verify=False)   
    xml = r.content.decode(encoding='UTF-8')
    xml = xml + "
"
    if xml[:5] == "<?xml":
        file = open("mobile2.xml", 'a')
        file.write(xml)
        #time.sleep(10)
        file.close()
#Mobile 2 - More detail report
print ("PPS XML Mobile Exporter for Casper Finished")

Gabe Shackney
Princeton Public Schools

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+11
  • Contributor
  • 176 replies
  • June 8, 2015

I'm not using Web Help desk, but the API is the API.

Just tried the compexport_xml.py from the SDK. Seems to work as expected on my JSS (9.72) using the system Python 2.7.6 on 10.10.3.

Did you change anything with your certificates to patch SSL? Are you forcing SSLv3 in your version of the export script for some reason?


Forum|alt.badge.img+18
  • Author
  • Esteemed Contributor
  • 831 replies
  • Answer
  • June 9, 2015

Nothing I know of changed, but looks like we found a work around with this xml:

#for Python 3.4 - Need to run this command to install requests library to python: pip install requests
import requests
import warnings
import time

warnings.filterwarnings('ignore')
print ("PPS XML Mobile Exporter for Casper Start")
#Open URL 
#Using the URL, UserName, Password, and turning off the certificate verification since the certificate is self signed
#always test url with browser first.
url = "https://casper:8443/JSSResource/mobiledevices"
r = requests.get(url, auth=('USERNAME', 'PASSWORD'),verify=False)
xml = r.content.decode(encoding='UTF-8')
#Open URL

#File
#Creates a connection to an output file and write out the XML data and close the file
file = open("mobile1.xml", 'w')
file.write(xml)
file.close()
#File

#Over Write File
#This needs to be done, so we have a new blank file, since the file is appended with every run through the loop
file = open("mobile2.xml", 'w')     
xml = ""
file.write(xml)
file.close()
#Over Write File

#Mobile 2 - A more detail report loop, to get more detail on each mobile device, as a short cut I loop through more times then we
#have mobile devices, since I only write a line out if the data is xml, if the id is not valid, an html file is returned and is ignored.
for count in range(1,20000):
    x = str(count)
    url = "https://casper:8443/JSSResource/mobiledevices/id/" + x + "/subset/General%26Location%26Purchasing"
    r = requests.get(url, auth=('USERNAME', 'PASSWORD'),verify=False)   
    xml = r.content.decode(encoding='UTF-8')
    xml = xml + "
"
    if xml[:5] == "<?xml":
        file = open("mobile2.xml", 'a')
        file.write(xml)
        #time.sleep(10)
        file.close()
#Mobile 2 - More detail report
print ("PPS XML Mobile Exporter for Casper Finished")

Gabe Shackney
Princeton Public Schools


Forum|alt.badge.img+11
  • Contributor
  • 176 replies
  • June 9, 2015

Glad to hear! I've been a big fan of the requests library as of late.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings