cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
881
Views
0
Helpful
2
Replies

Deleting local user from Unity connection using Python

Hi All,

I am able to remove the user and getting response 200. But when i login into unity connection i got that user still in unity connection.Pls see response codes from unity connection.


**********

Response [200]>

25dbb51e-4bb5-45d3-9104-b19ad5045aca

http://XXX.XXX.XXX.XXX/vmrest/users/25dbb51e-4bb5-45d3-9104-b19ad5045aca

<Response [200]>

****************************

import requests

import json

#HTTP headers to include

UserHeaders = {'Accept':'application/json', 'content-type':'application/json','connection':'keep_alive'}

#define Alias to be removed

userAlias = 'XXXXXX'

#Define your Unity connection server URL here

UCURL = 'http://XXX.XXX.XXX.XXX/vmrest/users/?query=(alias is ' + userAlias + ')'

#Forming the request using "Request" library to submit to the server.

ObIDGetResponse = requests.get(UCURL, headers=UserHeaders, auth=('XXXXXX','XXXXXX'), verify=False)

print(ObIDGetResponse)

#Using the json dot notation call to get the JSON response from the server in a dictionary format for Python to process

UserGet = ObIDGetResponse.json()

#Extracting the specific value from the dictionary using the defined keys from the JSON response

UserObId = UserGet['User']['ObjectId']

#Printing the Object ID to console

print (UserObId)

#Definining the URL used to delete the user

deleteURL = 'http://XXX.XXX.XXX.XXX/vmrest/users/' + UserObId

print(deleteURL)

#Forming the Delete request using the "Requests" library

UltimateDestruction = requests.delete(deleteURL, headers=UserHeaders, auth=('XXXXXX', 'XXXXXX'), verify=False)

#Printing the HTTP response from the server to console

print (UltimateDestruction)

2 Replies 2

lindborg
Cisco Employee
Cisco Employee

200 would be what you'd see with a GET to that url - a DELETE that is successful would typically return a 204 (no content) - I just tried it on a 10.0 and an 11.5 server I have here and got a 204 back from both just issuing the delete via POSTMAN -

My unity connection version is 10.5.X and Python is 2.7.12  Could you please post the code. Which python version you are using ?

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: