Reputation: 45
I'm trying to make a pinner app with official Pinterest API. I completed most of the features, but I'm struggling with creating pins.
I can't create a pin with my local files like:
MEDIA_SOURCE =
{
"source_type": "image_url",
"content_type": "image/jpeg",
"data": "string",
'url':'C:/Users/USER/Images/Cat/3D62226C-A2F9-4171-BF04-B03AF416CD46.jpg'
}
HTTP response body: {"code":1,"message":"Parameter 'image url' with the value 'C:/Users/USER/Images/Cat/3D62226C-A2F9-4171-BF04-B03AF416CD46.jpg' is not a valid URL format."}
Pinterest gives me this error.
I tried with this media_source template. It works like expected. So, I can use https url's in this dictionary but not local file url's. I think I should change source_type value in the dictionary but I couldn't find the parameters that can be usable for this source_type value.
MEDIA_SOURCE =
{
"source_type": "image_url",
"content_type": "image/jpeg",
"data": "string",
'url':'https://URL-TO-IMAGE.jpg'
}
Upvotes: 0
Views: 774
Reputation: 1
Issue: The Pinterest API expects the image to be accessible via a publicly available URL. Local file paths such as C:/Users/USER/Images/... are not valid because the Pinterest server cannot access your local filesystem.
Solution: To resolve this issue, you need to upload the image from your local system to a publicly accessible location and then use that URL in the API request.
Steps: Upload the image to a public image hosting service: You can use any of the following services to host your image:
Or any other image hosting service that provides a publicly accessible URL for your image. Use the publicly accessible URL: Once the image is uploaded, the service will provide a URL that points to the image. You need to use this URL in the media_source dictionary when making the API request.
MEDIA_SOURCE = {
"source_type": "image_url",
"content_type": "image/jpeg",
"data": "string", // Optional, depending on API documentation
"url": "https://your-image-hosting-service.com/path/to/image.jpg"
}
Upvotes: -1
Reputation: 45
I contacted with Pinterest developer support. Currently (June, 2023) local image sharing is not available. So we have to host image in a server. Than we can share a pin with this media source dictionary:
MEDIA_SOURCE =
{
"source_type": "image_url",
"content_type": "image/jpeg",
"data": "string",
'url':'https://URL-TO-IMAGE.jpg'
}
Upvotes: 1