Created
July 25, 2015 20:03
-
-
Save netmanchris/7b44052c5b03cd5480b3 to your computer and use it in GitHub Desktop.
Add Device to Custom View
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
def add_device_to_view(dev_list, view_id): | |
modify_custom_view_url = '''/imcrs/plat/res/view/custom/'''+ str(view_id) | |
device_list = [] | |
for i in dev_list: | |
dev_id = {'id': i['id'] } | |
device_list.append(dev_id) | |
payload = '''{"device":'''+ json.dumps(device_list) + '''}''' | |
f_url = url+modify_custom_view_url | |
r = requests.put(f_url, data = payload, auth=auth, headers=headers) #creates the URL using the payload variable as the contents | |
r.status_code | |
if r.status_code == 204: | |
print ("Device Succesfully Added") | |
else: | |
print ("An Error has occured") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment