Reputation: 31
this is my following code when i try to create pin i get error board not found even though i have a board with following ID.
When i try to list boards throught API i get 0 boards even though i have 2 boards in my pinterest account
export const createPinterestPin = async () => {
try {
const accessToken = process.env.PINTEREST_ACCESS_TOKEN!
if (!accessToken) throw new Error('Access token is required');
const request = await fetch(`https://api-sandbox.pinterest.com/v5/pins`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify({
data: {
title: "My first pin",
board_id: "1104226471076157432",
media_source: {
source_type: "image_url",
url: "https://dummyimage.com/600x400/000/fff"
},
description: "My first pin on Pinterest",
}
})
})
const response = await request.json();
} catch (error: any) {
console.log(`Error in createPinterestPin: ${error.message}`)
throw new Error(error)
}
}
Upvotes: 0
Views: 30