2017-09-19 106 views
0

BigCommerce API documentation表明,图像文件可以通过API进行上传,而无需在其他地方先上传:附加图片文件到的Bigcommerce产品

POST /catalog/products/{product_id}/images

在产品创建的图像。公开访问的URL和文件(表格后)有效参数

重点煤矿。我的尝试,在下面的变化,主要回来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 [email protected]_123.jpg \ 
    -F image_url=image_123.jpg 

什么是一个正确的形成要求的样子,那POST S上的图像文件的产品?


相关:

回答

0

甲正确形成请求看起来像这样:

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 '[email protected]/img_2405.jpg' 

然而,某些图像可以导致误导性的错误;如this one.

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