instagram_private_api icon indicating copy to clipboard operation
instagram_private_api copied to clipboard

Bad Request error on upload photo

Open milansachithra opened this issue 4 years ago • 7 comments

Which client are you using? - app (instagram_private_api/)

The upload_photo method returns "Bad request" error.

Error message:

instagram_private_api.errors.ClientError: Bad Request

Code:

image = open(r'img\e1.jpg', 'rb')
image_read = image.read()
i2 = base64.b64encode(image_read)
res = api.post_photo(photo_data=i2, size=(720, 720))
print(res)

Error/Debug Log:

D:\users\Kavindu\Documents\fiverr\25 - Inster API\v8\venv\lib\site-packages\instagram_private_api\endpoints\upload.py:397: UserWarning: This endpoint has not been fully tested.
  warnings.warn('This endpoint has not been fully tested.', UserWarning)
Traceback (most recent call last):
  File "D:\users\Kavindu\Documents\fiverr\25 - Inster API\v8\venv\lib\site-packages\instagram_private_api\endpoints\upload.py", line 446, in post_photo
    response = self.opener.open(req, timeout=self.timeout)
  File "C:\Users\Kavindu\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\Kavindu\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Users\Kavindu\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\Kavindu\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Users\Kavindu\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/users/Kavindu/Documents/fiverr/25 - Inster API/v8/main.py", line 29, in <module>
    res = api.post_photo(photo_data=i2, size=(720, 720))
  File "D:\users\Kavindu\Documents\fiverr\25 - Inster API\v8\venv\lib\site-packages\instagram_private_api\endpoints\upload.py", line 450, in post_photo
    ErrorHandler.process(e, error_response)
  File "D:\users\Kavindu\Documents\fiverr\25 - Inster API\v8\venv\lib\site-packages\instagram_private_api\errors.py", line 141, in process
    raise ClientError(error_msg, http_error.code, error_response)
instagram_private_api.errors.ClientError: Bad Request

milansachithra avatar Jul 18 '20 05:07 milansachithra

Instagram closed off the endpoint, pretty sure someone abused the endpoint and they decided to take it away from all of us.

dexredux avatar Jul 25 '20 04:07 dexredux

Is there some other way to do this? I mean, there should be some product that allows you to automate this process

lrusik avatar Jul 25 '20 10:07 lrusik

I'm having the same issue

lrusik avatar Jul 25 '20 10:07 lrusik

too bad this clean way wont work anymore... but i have coded a ruff upload automation with chromedriver, kust rename it to .py

Functions.txt

chrishsr avatar Jul 27 '20 15:07 chrishsr

Instagram closed off the endpoint, pretty sure someone abused the endpoint and they decided to take it away from all of us.

but I have used c# library and it works. It has the same endpoint. (https://github.com/ramtinak/InstagramApiSharp)

milansachithra avatar Jul 29 '20 09:07 milansachithra

Instagram closed off the endpoint, pretty sure someone abused the endpoint and they decided to take it away from all of us.

but I have used c# library and it works. It has the same endpoint. (https://github.com/ramtinak/InstagramApiSharp)

Really? Then there is something wrong with this project and I was wrong. Usually a bad request means the endpoint is closed off. But since the c# API works, it looks like I know what I've gotta do next.

dexredux avatar Jul 29 '20 09:07 dexredux

Hey, I might have a solution to this problem. The colleagues from this repo have found out that the Instagram has made some changes in sending the password using a custom prefix tag. I did not have time to find this missing piece in this repo, but it could be worth a shot.

Here is the link to the reply.

https://github.com/jlobos/instagram-web-api/issues/118#issuecomment-629834968

Cheers, Chris

burny91 avatar Aug 18 '20 15:08 burny91