将图像文件附加到 BigCommerce 产品

Attach an image file to a BigCommerce Product

BigCommerce API documentation 建议可以通过 API 上传图片文件,而无需先在其他地方上传:

POST /catalog/products/{product_id}/images

Creates an image on a product. Publically accessible URLs and files (form post) are valid parameters

强调我的。我的尝试,下面的变体,大多返回 422 image_url must be present if uploading by url

curl -X POST \
  https://api.bigcommerce.com/stores/redacted/v3/catalog/products/123/images \
  -H 'accept: application/json' \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -H 'x-auth-client: redacted' \
  -H 'x-auth-token: redacted' \
  -F productImage=@img_123.jpg \
  -F image_url=image_123.jpg

POST产品图像文件的正确格式请求是什么样的?


相关:

正确格式的请求如下所示:

curl -X POST \
  https://api.bigcommerce.com/stores/js......7j/v3/catalog/products/32011/images \
  -H 'accept: application/json' \
  -H 'cache-control: no-cache'  \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -H 'x-auth-client: ts2.........................r0r' \
  -H 'x-auth-token: ihq.........................5b2' \
  -F 'image_file=@Downloads/img_2405.jpg'

但是,某些图像可能会导致误导性错误;比如this one.

不清楚文件的 属性 是什么导致了错误,但压缩或以其他方式重新保存图像可以解决问题。