Hello,
I am trying to add user profile picture with API in Python with this code :
image_path = download_image(user['picture.large'])
with open(image_path, 'rb') as img:
files = {'userphoto[]': (os.path.basename(image_path), img, 'image/jpeg')}
url = f"{OSSN_URL}/api/v1.0/photos_profile_add?api_key_token={OSSN_API_KEY}&guid={guid}"
photo_response = requests.post(url, files=files)
print("Photo Upload Response:", photo_response.text)
os.remove(image_path)
But everytime I get this message :
Photo Upload Response: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource could not be found on this server.</p>
<p>Additionally, a 406 Not Acceptable
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
I also tried with a CURL command, with the same issue…
It's working thanks a lot !
Because its single photo you seens sending array userphoto[] should be only userphoto i guess
Thanks !
I disabled Modsecurity for the test.
But now I have a different error with the payload :
"message": "ossnservices:cannotaddalbum:photo"
It is strange, because I used to install OSSN without problem with the same script and it worked…
Maybe your provider mod security blocking this request. You can ask them to disable mod security for your website.
Alternatively try localhost ossn installation and see if it works or not.
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.