Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG - SDK Client pin creation fails but endpoint is working #128

Open
tallestJake opened this issue May 14, 2024 · 1 comment
Open

BUG - SDK Client pin creation fails but endpoint is working #128

tallestJake opened this issue May 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@tallestJake
Copy link

tallestJake commented May 14, 2024

Describe the bug

I'm able to create pins using the python requests package and endpoint provided in the Pinterest API docs but when I try using the SDK I get permissions error.

To Reproduce
Unsuccessful using SDK:

from pinterest.client import PinterestSDKClient
from pinterest.organic.pins import Pin

PinterestSDKClient.set_default_access_token(<token>)

params = {
    "board_id": <board_id>,
    "ad_account_id": <ad_account>,
    "description": <description>,
    "link":  <link>,
    "title": <title>,
    "media_source":{
        'source_type':'image_base64',
        'data': <image>,
        'content_type':"image/png"
    }
Pin.create(**params)

The above returns the following error:

Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '38', 'pinterest-version': 'c7fe355', 'x-content-type-options': 'nosniff', 'x-frame-options': 'DENY', 'Access-Control-Allow-Credentials': 'true', 'p3p': 'CP="Pinterest does not have a P3P policy. You can find our privacy policy at https://www.pinterest.com/_/_/policy/privacy-policy."', 'x-envoy-upstream-service-time': '83', 'pinterest-generated-by': 'tpp-api-canary-0a0308c3', 'X-RateLimit-Limit': '100, 100;w=1, 1000;w=60', 'X-RateLimit-Remaining': '99', 'X-RateLimit-Reset': '1', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'x-pinterest-rid': '6639680265060241', 'Date': 'Tue, 14 May 2024 16:13:42 GMT', 'Alt-Svc': 'h3=":443"; ma=600', 'Connection': 'keep-alive', 'Set-Cookie': '_ir=0; Max-Age=1800; HttpOnly; Path=/; Secure', 'AKAMAI-GRN': '0.de6533b8.1715703222.1e8acbde', 'X-CDN': 'akamai'})
HTTP response body: {"code":50,"message":"Pin not found."}

The following python request works

import requests
params = {
    "board_id": <board_id>,
    "ad_account_id": <ad_account>,
    "description": <description>,
    "link":  <link>,
    "title": <title>,
    "media_source":{
        'source_type':'image_base64',
        'data': <image>,
        'content_type':"image/png"
    }
auth = {'Authorization': 'Bearer {}'.format(<token>)}
auth["Content-Type"] = "application/json"
pin = requests.post('https://api.pinterest.com/v5/pins', json=params, headers=self.auth).json()

Screenshot of response using above method:
image

Additional Details:

  • MacOS Sonoma 14.3 M1 chip
  • pinterest-api-sdk==0.2.1
@tallestJake tallestJake added the bug Something isn't working label May 14, 2024
@Lonzarostore
Copy link

hoe los ik dat op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants