0

製品のカスタム フィールドを更新しようとしています。

管理インターフェースから手動で行う方法に関するガイドを見つけました

API ドキュメントでは、製品のカスタム フィールドを直接変更することはできず、アクセスのみが可能であることが示唆されています。

次に考えたのは、製品を更新することでした

これは、製品の既存の custom_field です。

{
  "url"=> "https://storename.mybigcommerce.com/api/v2/products/32/customfields.json",
  "resource"=>"/products/32/customfields"
}

URL/リソースを変更し、ハッシュを更新のために送り返そうとすると、400 Bad Request:(

new_custom_fields = { 
"url" => "https://storename.mybigcommerce.com/api/v2/products/75/customfields.json", 
"resource" => "/products/75/customfields"
}

api.update_products(75, {"custom_fields" => new_custom_fields})
RuntimeError: Failed to parse Bigcommerce response: 400 Bad Request

考え?

4

3 に答える 3

2

これは Bigcommerce API のバグのようです。現在、カスタム フィールドに対する GET リクエストのみがサポートされています。

http://developer.bigcommerce.com/api/products/customfields

それがおそらくあなたが400を打っている理由です。

于 2013-05-09T18:05:17.350 に答える
0

このコードを試してください:

$headers = array(
"Content-type: application/json",
//"Authorization: Basic " . base64_encode($credentials)
);
$name='箇条書き';
$data_array = array('name'=>'Bullet Point','text'=>'Bullet Point value');
$body=json_encode($data_array);
// 現在の URL を取得し、'?' で分割します。
$ch = curl_init('https://www.abc.mybigcommerce.com/api/v2/products/1122/customfields.json'); //接続を開く
curl_setopt($ch, CURLOPT_TIMEOUT, 60); //BC API ガイド v1 PDF の例から 60 秒に設定
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //すべてのヘッダー データをロードします
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $ch, CURLOPT_USERPWD, "admin:api-key");
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$result = curl_exec($ch); //post
curl_close($ch);を実行します。

于 2013-12-11T10:04:57.870 に答える
0

これがRubyに役立つかどうかはわかりませんが、PHPを使用している人には役立つかもしれません.phpを使用して製品にカスタムフィールドを作成できます。製品 ID と、カスタム フィールドの「名前」と「テキスト」の値だけが必要です。

$data_array = array('name' => 'gender', 'text' => 'male');
BigCommerce::createProductCustomField('17', $data_array);

カスタム フィールドを更新しようとしたことはありませんが、作成が機能する場合は、次のようにして現在のカスタム フィールドを更新することもできます。

BigCommerce::updateProductCustomField($product_id, $id, $object);

更新する商品の $product_id と、更新するカスタム フィールドの $id が必要です。$object は、上記の $data_array のような配列である必要があります。

BC の PHP クライアントの詳細: https://github.com/bigcommerce/bigcommerce-api-php

幸運を!

于 2013-11-22T17:31:03.447 に答える