Skip to content

Instantly share code, notes, and snippets.

@netmanchris
Created July 25, 2015 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netmanchris/7b44052c5b03cd5480b3 to your computer and use it in GitHub Desktop.
Save netmanchris/7b44052c5b03cd5480b3 to your computer and use it in GitHub Desktop.
Add Device to Custom View
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