Skip to content

Instantly share code, notes, and snippets.

@jpadilla
Last active March 16, 2021 14:42
Show Gist options
  • Save jpadilla/b086af18f65d8f6f6800049957c32686 to your computer and use it in GitHub Desktop.
Save jpadilla/b086af18f65d8f6f6800049957c32686 to your computer and use it in GitHub Desktop.
import http.client
conn = http.client.HTTPSConnection("https://YOUR_DOMAIN")
payload = "{ \"roles\": [ \"ROLE_ID\", \"ROLE_ID\" ] }"
headers = {
'authorization': "Bearer MGMT_API_ACCESS_TOKEN",
'cache-control': "no-cache",
'content-type': "application/json"
}
conn.request("POST", "/api/v2/users/USER_ID/roles", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import http.client
conn = http.client.HTTPSConnection("https://YOUR_DOMAIN")
headers = { 'authorization': "Bearer YOUR_MGMT_API_ACCESS_TOKEN" }
conn.request("GET", "/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import http.client
conn = http.client.HTTPSConnection("https://YOUR_DOMAIN")
headers = { 'authorization': "Bearer YOUR_MGMT_API_ACCESS_TOKEN" }
conn.request("GET", "/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import http.client
conn = http.client.HTTPSConnection("https://YOUR_DOMAIN")
headers = { 'authorization': "Bearer YOUR_MGMT_API_ACCESS_TOKEN" }
conn.request("GET", "/api/v2/users?q=name%3Ajohn*&search_engine=v3", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment