Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search

ksho

Member
  • Posts

    1
  • Joined

  • Last visited

  1. Hi! I'm trying to programmatically upload photos to my products (https://developers.squarespace.com/commerce-apis/upload-product-image). CURL Requests via Insomnia will work, but I cannot for the life of me get uploads via Python working. My code (generated from a working Insomnia request): url = "https://api.squarespace.com/1.0/commerce/products/MY_PRODUCT_ID/images" payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"MY_FILE_NAME.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n\r\n-----011000010111000001101001--\r\n" headers = { "Authorization": "Bearer MY_TOKEN", "User-Agent": "MY_USER_AGENT", "Content-Type": "multipart/form-data; boundary=---011000010111000001101001" } response = requests.post(url, data=payload, headers=headers) I keep hitting this error: "The provided file could not be read as an image." Has anyone done this before? What am I missing? If anyone has code examples from any language I'm happy to reverse engineer!
×
×
  • Create New...