使用Schema文件发布一个产品
Schema体系发布一个产品
1.请求参数:
请求URL:
POST https://kf.fw199.com/gateway/taobao/tmall/product/schema/add
参数名 | 类型 | 必须 | 示例值 | 说明 |
---|---|---|---|---|
appid | String | true | uwkahf@jfs92 | 合作伙伴AppId |
timestamp | String | true | 1633618722 | 当前时间戳 |
tb_seller_nick | String | true | kingdo | 淘宝卖家店铺登录账号,非店铺名称 |
sign | String | true | 999de41d862efaa6f1084ead3b3ba480 | 如何计算生成见示例代码 |
category_id | Number | true | 328818231125 | 商品发布的目标类目,必须是叶子类目 |
xml_data | Number | true | <itemrule><field id="prop_14837340 " name="体积 (含包装)" type="input "></field></itemrule> |
根据tmall.product.add.schema.get生成的产品发布规则入参数据 |
brand_id | Number | false | 3232 | 品牌ID,可通过查询商家被授权品牌列表和类目列表接口获取 |
xml_data示例
<itemRule>
<field id="prop_20000" name="品牌" type="singleCheck">
<rules>
<rule name="requiredRule" value="true"/>
</rules>
<value>222</value>
</field>
<field id="prop_13021751" name="货号" type="input">
<rules>
<rule name="requiredRule" value="true"/>
</rules>
<value>hh100</value>
</field>
<field id="prop_122216347" name="上市年份季节" type="singleCheck">
<value>828914261</value>
</field>
<field id="prop_13328588" name="成分含量" type="singleCheck">
<rules>
<rule name="requiredRule" value="true"/>
</rules>
<value>145656297</value>
</field>
<field id="prop_122216586" name="服装版型" type="singleCheck">
<rules>
<rule name="requiredRule" value="true"/>
</rules>
<value>3267162</value>
</field>
<field id="prop_122216562" name="衣长" type="singleCheck">
<rules>
<rule name="requiredRule" value="true"/>
</rules>
<value>22561361</value>
</field>
<field id="prop_122216348" name="袖长" type="singleCheck">
<rules>
<rule name="requiredRule" value="true"/>
</rules>
<value>29444</value>
</field>
<field id="prop_20021" name="面料" type="singleCheck">
<rules>
<rule name="requiredRule" value="true"/>
</rules>
<value>105255</value>
</field>
<field id="product_images" name="产品图片" type="complex">
<fields>
<field id="product_image_0" name="产品图片" type="input">
<rules>
<rule name="valueTypeRule" value="url"/>
<rule name="requiredRule" value="true"/>
</rules>
<value>https://img.alicdn.com/imgextra/i2/661153176/TB2_4DUopuWBuNjSspnXXX1NVXa_!!661153176.jpg</value>
</field>
<field id="product_image_1" name="产品图片" type="input">
<rules>
<rule name="valueTypeRule" value="url"/>
</rules>
</field>
<field id="product_image_2" name="产品图片" type="input">
<rules>
<rule name="valueTypeRule" value="url"/>
</rules>
</field>
<field id="product_image_3" name="产品图片" type="input">
<rules>
<rule name="valueTypeRule" value="url"/>
</rules>
</field>
<field id="product_image_4" name="产品图片" type="input">
<rules>
<rule name="valueTypeRule" value="url"/>
</rules>
</field>
</fields>
</field>
</itemRule>
2. 请求示例代码(Java)
@Test
public void TmallProductSchemaAddRequestUrl() throws Exception {
String tb_seller_nick = Config.TBSellerNick;
//业务参数
Map<String, String> data = new HashMap<String, String>();
data.put("appid", Config.AppId);
data.put("tb_seller_nick", tb_seller_nick);
Long timestamp = System.currentTimeMillis() / 1000;
data.put("timestamp", timestamp.toString());
data.put("category_id", "201241307");
// data.put("brand_id", "10000497");
String xmlData = "<itemRule>\n" +
" <field id=\"prop_20000\" name=\"品牌\" type=\"singleCheck\">\n" +
" <rules>\n" +
" <rule name=\"requiredRule\" value=\"true\"/>\n" +
" </rules>\n" +
" <value>222</value>\n" +
"\n" +
" </field>\n" +
" <field id=\"prop_13021751\" name=\"货号\" type=\"input\">\n" +
" <rules>\n" +
" <rule name=\"requiredRule\" value=\"true\"/>\n" +
" </rules>\n" +
" <value>hh100</value>\n" +
" </field>\n" +
" <field id=\"prop_122216347\" name=\"上市年份季节\" type=\"singleCheck\">\n" +
" <value>828914261</value> \n" +
" </field>\n" +
" <field id=\"prop_13328588\" name=\"成分含量\" type=\"singleCheck\">\n" +
" <rules>\n" +
" <rule name=\"requiredRule\" value=\"true\"/>\n" +
" </rules> \n" +
" <value>145656297</value>\n" +
" </field>\n" +
" <field id=\"prop_122216586\" name=\"服装版型\" type=\"singleCheck\">\n" +
" <rules>\n" +
" <rule name=\"requiredRule\" value=\"true\"/>\n" +
" </rules>\n" +
" \n" +
" <value>3267162</value>\n" +
" </field>\n" +
" <field id=\"prop_122216562\" name=\"衣长\" type=\"singleCheck\">\n" +
" <rules>\n" +
" <rule name=\"requiredRule\" value=\"true\"/>\n" +
" </rules>\n" +
" <value>22561361</value>\n" +
" \n" +
" </field>\n" +
" <field id=\"prop_122216348\" name=\"袖长\" type=\"singleCheck\">\n" +
" <rules>\n" +
" <rule name=\"requiredRule\" value=\"true\"/>\n" +
" </rules>\n" +
" <value>29444</value>\n" +
" \n" +
" </field>\n" +
" <field id=\"prop_20021\" name=\"面料\" type=\"singleCheck\">\n" +
" <rules>\n" +
" <rule name=\"requiredRule\" value=\"true\"/>\n" +
" </rules>\n" +
" <value>105255</value>\n" +
" \n" +
" </field>\n" +
" <field id=\"product_images\" name=\"产品图片\" type=\"complex\">\n" +
" <fields>\n" +
" <field id=\"product_image_0\" name=\"产品图片\" type=\"input\">\n" +
" <rules>\n" +
" <rule name=\"valueTypeRule\" value=\"url\"/>\n" +
" <rule name=\"requiredRule\" value=\"true\"/>\n" +
" </rules> \n" +
" <value>https://img.alicdn.com/imgextra/i2/661153176/TB2_4DUopuWBuNjSspnXXX1NVXa_!!661153176.jpg</value>\n" +
"\n" +
" </field>\n" +
" <field id=\"product_image_1\" name=\"产品图片\" type=\"input\">\n" +
" <rules>\n" +
" <rule name=\"valueTypeRule\" value=\"url\"/>\n" +
" </rules>\n" +
" </field>\n" +
" <field id=\"product_image_2\" name=\"产品图片\" type=\"input\">\n" +
" <rules>\n" +
" <rule name=\"valueTypeRule\" value=\"url\"/>\n" +
" </rules>\n" +
" </field>\n" +
" <field id=\"product_image_3\" name=\"产品图片\" type=\"input\">\n" +
" <rules>\n" +
" <rule name=\"valueTypeRule\" value=\"url\"/>\n" +
" </rules>\n" +
" </field>\n" +
" <field id=\"product_image_4\" name=\"产品图片\" type=\"input\">\n" +
" <rules>\n" +
" <rule name=\"valueTypeRule\" value=\"url\"/>\n" +
" </rules>\n" +
" </field>\n" +
" </fields>\n" +
" </field>\n" +
"</itemRule>";
data.put("xml_data", xmlData);
data.put("sign", Utils.Sign(data, Config.AppSecret));
// 调用服务API
String rsp = doHttpRequest(Config.TmallProductSchemaAddRequestUrl, data);
// 需要进行编码转换,比如 "\u003c" 转成 "<" , "\u003e" 转成 ">" 等
String unescapeRsp = StringEscapeUtils.unescapeJavaScript(rsp);
System.out.println(unescapeRsp);
}
3. 返回结果
返回结果如下
{
"code":0,
"message":"ok",
"data":{
"add_product_result":"<itemrule> <field id=\"product_id\" name=\"产品ID\" type=\"input \">1221<\/field> <field id=\"create_time\" name=\"创建时间\" type=\"input \">2014-01-01 00:00:00<\/field> <itemrule>",
"request_id":"zyqf3xu5bnem"
},
"trace_id":""
}
说明: code为0表示成功,非0为失败,message会包含失败原因, add_product_result为新发产品结果。
文档更新时间: 2023-04-14 22:19 作者:admin