# 500 error POST/users/\[userID\]/picture python requests

**URL:** <https://devforum.zoom.us/t/500-error-post-users-userid-picture-python-requests/30637>\
**Category:** API and Webhooks\
**Created:** [September 17, 2020, 10:17pm UTC](https://devforum.zoom.us/t/500-error-post-users-userid-picture-python-requests/30637 "2020-09-17T22:17:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zachary.burnaby](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/zachary.burnaby/32/15521_2.png) [@zachary.burnaby](https://devforum.zoom.us/u/zachary.burnaby)\
**Post date:** [September 17, 2020, 10:17pm UTC](https://devforum.zoom.us/t/500-error-post-users-userid-picture-python-requests/30637/1 "2020-09-17T22:17:18Z")

</div>

**Description**  
I have written a bunch of successful api requests for managing my High School’s recordings, but we wanted to remove all student’s profile pictures/set them all to a default. I copied my interface function template, and made all the right changes and tried to make the call. I get a 500 error. I’ve changed almost all parts of my function, including copying the sample code from the API page. Not exactly sure what’s going on here.

**Error**  
\<Response [500]\>  
response.text gives HTML for a webpage displaying “Internal Service Error”

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
JWT, I can send other requests so I’m pretty sure it’s not this.

**Which Endpoint/s?**

> **[Upload a User's Profile Picture - Users - Zoom API - API Reference](https://marketplace.zoom.us/docs/api-reference/zoom-api/users/userpicture)**
>
> Upload a user's profile picture.
> 
> Provide multipart/form-data as the value of the content-type header for this request. 
> 
> Scopes: user:write:admin user:...

**My Code:**  
def postUserProfilePicture(API\_KEY, API\_SECRET, userID):  
----headers = {‘authorization’: ‘Bearer %s’ % generateToken(API\_KEY, API\_SECRET),  
-------------------‘content-type’: ‘multipart/form-data’}  
----file = {“pic\_file”: open(“kennedySeal.png”, ‘rb’)}  
----res = requests.post(“[https://api.zoom.us/v2/users/](https://api.zoom.us/v2/users/)” + userID + “/picture”, headers=headers, files=file)  
----return(res)

---

<div class="post-metadata">

**Author:** ![ojus.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ojus.zoom/32/734_2.png) [@ojus.zoom](https://devforum.zoom.us/u/ojus.zoom)\
**Post date:** [September 18, 2020, 2:41pm UTC](https://devforum.zoom.us/t/500-error-post-users-userid-picture-python-requests/30637/2 "2020-09-18T14:41:24Z")

</div>

Hi @zachary.burnaby,

Happy Friday.

Please use this code logic to use the profile picture API in python:

```
import requests
url = "https://api.zoom.us/v2/users/userID/picture"
img_path = ''

headers = {'Authorization': 'Bearer Token',
           'Accept': 'application/json',
           }
files = {'pic_file': (img_path.split('/')[-1], open(img_path, 'rb'), 'image/png')}

response = requests.post(url, files=files, headers=headers)
print response.content 

```

Let me know if this helps.

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [October 19, 2020, 12:41am UTC](https://devforum.zoom.us/t/500-error-post-users-userid-picture-python-requests/30637/3 "2020-10-19T00:41:29Z")

</div>

Closed on October 19, 2020, 12:41am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
