Skip to content

Instantly share code, notes, and snippets.

@shemogumbe
Created April 19, 2024 13:01
Show Gist options
  • Save shemogumbe/bfb38e018e5ce15b98b8b0d2433d7ba0 to your computer and use it in GitHub Desktop.
Save shemogumbe/bfb38e018e5ce15b98b8b0d2433d7ba0 to your computer and use it in GitHub Desktop.
Delete profile picture
import requests
# Endpoint URL
url = "https://graph.microsoft.com/v1.0/me/photo/$value"
# Token (replace with your actual token)
token = "<your-token-here>"
# Headers
headers = {
"Authorization": f"Bearer {token}",
}
# Send DELETE request
response = requests.delete(url, headers=headers)
# Check response status
if response.status_code == 200:
print("Profile photo deleted successfully!")
else:
print("Failed to delete profile photo. Status code:", response.status_code)
print("Response:", response.text)
@shemogumbe
Copy link
Author

This prints out the message:
"Profile photo deleted successfully!"

and the profile picture is now empty on GE, REQUEST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment