I want to upload image to product app using the API but when i try to access the fields in product it does not list anything with the name ‘image’ or field_type. Is there any way to upload the image using API?
1 Like
import requests
# Dane dostępowe do Pipedrive
API_TOKEN = 'your_token'
PRODUCT_ID = 2747
# Ścieżka do pliku obrazu
file_path = 'image.jpg'
# URL do dodania zdjęcia
url = f'https://yourorganisation.pipedrive.com/api/v1_internal/products-api/products/{PRODUCT_ID}/images?api_token={API_TOKEN}&strict_mode=true'
with open(file_path, 'rb') as file:
files = {
'data': ('image.jpg', file, 'image/jpeg')
}
response = requests.post(url, files=files)
if response.status_code == 200:
print("Image uploaded successfully:", response.json())
else:
print(f"Error: {response.status_code}")
print(response.json())