bstoilov / py3-pinterest

Fully fledged Python Pinterest client
MIT License
293 stars 104 forks source link

Can't post a new pin #175

Open KristyAnon opened 2 years ago

KristyAnon commented 2 years ago

Hi, I just updated my code to the version 1.3.0, and now I can't post a new pin. This is my code: pin_response = pinterest.pin(board_id='', section_id=None, image_url='https://dummyimage.com/200x200/000/fff.jpg&text=testing', description='testing', link='https://dummyimage.com/200x200/000/fff.jpg&text=testing' )

And this is the error that I'm getting Traceback (most recent call last): File "I:\myPInt\python\py3-pinterest-master.vCN\zz_testing.py", line 108, in <module> pin_response = pinterest.pin(board_id='', File "I:\myPInt\python\py3-pinterest-master.vCN\py3pin\Pinterest.py", line 595, in pin return self.post(url=PIN_RESOURCE_CREATE, data=data) File "I:\myPInt\python\py3-pinterest-master.vCN\py3pin\Pinterest.py", line 170, in post return self.request( File "I:\myPInt\python\py3-pinterest-master.vCN\py3pin\Pinterest.py", line 162, in request response.raise_for_status() File "C:\Python\lib\site-packages\requests\models.py", line 960, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://www.pinterest.com/resource/PinResource/create/

Any idea how to resolve it?

Thanks, Kristy

2022-05-10 203719

bstoilov commented 2 years ago

This happens if the board id is wrong. I just tested locally and it seems to be working

benx13 commented 1 year ago

@KristyAnon did you fix it I'm getting the same issue

Humenuik commented 1 year ago

Saw that there wasn't an answer as to getting the board_id correct. To get the correct board_id:

import pprint

pprint.pprint(pin.boards(username=username))

This will print out the JSON in an easily readable format. Look for id: value for the board with name: board you want. Use the id value for the id.

If you are trying to make this scale, you can probably just make a function to loop through all current boards looking for the one you want to add to, if it finds the name, it stores the id value to upload the pin to. If it doesn't find the name, it creates the board and stores the id to upload the PIN. Hope this helps anyone who gets stuck.

quick edit: Don't use the ID under owner. That is your JSON ID value, not the board.