I am trying to use python lib requests to load an image in Imgur using imgur api . Api returns 400, stating that the file is either unsupported or corrupt. I do not think the image is damaged (I can view it locally) and I tried .jpg , .jpeg and .png . Here is the code:
api_key = "4adaaf1bd8caec42a5b007405e829eb0" url = "http://api.imgur.com/2/upload.json" r = requests.post(url, data={'key': api_key, 'image':{'file': ('test.png', open('test.png', 'rb'))}})
The exact error message is:
{"error":{"message":"Image format not supported, or image is corrupt.","request":"\/2\/upload.json","method":"post","format":"json","parameters":"image = file, key = 4adaaf1bd8caec42a5b007405e829eb0"}}
Let me know if I can provide more information. I am pretty green with Python and expect this to be a simple blunder, can anyone explain what?
source share