修改地址内容
代会员调用 · 必带
x-on-behalf-of
需 x-idempotency-key
⚠ 整条替换,不是逐字段合并。 必填六项要齐全,跟新增一样 ——做成合并的话,漏传 line2 到底是「清空它」还是「保持原样」永远说不清,而那种歧义在寄件地址上会真的把包裹寄丢。
⚠ 不碰默认位。 设默认是另一个端点。一次「改内容」顺带改掉「寄到哪」,正是这类接口最容易长出来的暗门。
⚠ 已经用这条地址下过的实体卡订单不受影响:下单那一刻地址就快照进订单行了。改地址不会让在途包裹改道,也不会让历史订单的寄送地址跟着变。
路径参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id |
string | 必填 |
请求头
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
x-idempotency-key |
string | 必填 | |
x-on-behalf-of |
string | 必填 |
请求体
这个 operation 还没有在 spec 里声明请求体字段。
响应
200已更新
400
invalid_fields(带 fields[].key)· idempotency_key_required404
not_found请求
curl -X PATCH 'https://api.zise.com/v1/shipping-addresses/{id}' \
-H 'x-auth-token: Bearer $TOKEN' \
-H 'x-on-behalf-of: $MEMBER_ID' \
-H 'x-idempotency-key: $IDEMPOTENCY_KEY' \
-H 'content-type: application/json' \
-d '{
"country": "HK",
"recipient_last": "陈",
"recipient_first": "小明",
"phone_code": "852",
"phone_number": "51234567",
"city": "香港",
"line1": "皇后大道中 15 号",
"postal_code": "000000"
}'const res = await fetch("https://api.zise.com/v1/shipping-addresses/{id}", {
method: "PATCH",
headers: {
"x-auth-token": "Bearer $TOKEN",
"x-on-behalf-of": "$MEMBER_ID",
"x-idempotency-key": "$IDEMPOTENCY_KEY",
"content-type": "application/json",
},
body: JSON.stringify({
"country": "HK",
"recipient_last": "陈",
"recipient_first": "小明",
"phone_code": "852",
"phone_number": "51234567",
"city": "香港",
"line1": "皇后大道中 15 号",
"postal_code": "000000"
}),
});
// 金额按字符串读,别让它变成 number
const data = await res.json();import requests
res = requests.patch(
"https://api.zise.com/v1/shipping-addresses/{id}",
headers={
"x-auth-token": "Bearer $TOKEN",
"x-on-behalf-of": "$MEMBER_ID",
"x-idempotency-key": "$IDEMPOTENCY_KEY",
"content-type": "application/json",
},
json={
"country": "HK",
"recipient_last": "陈",
"recipient_first": "小明",
"phone_code": "852",
"phone_number": "51234567",
"city": "香港",
"line1": "皇后大道中 15 号",
"postal_code": "000000"
},
)
# 金额用 Decimal(str(...)),不要 float
data = res.json()req, _ := http.NewRequest("PATCH", "https://api.zise.com/v1/shipping-addresses/{id}",
strings.NewReader(`{
"country": "HK",
"recipient_last": "陈",
"recipient_first": "小明",
"phone_code": "852",
"phone_number": "51234567",
"city": "香港",
"line1": "皇后大道中 15 号",
"postal_code": "000000"
}`))
req.Header.Set("x-auth-token", "Bearer $TOKEN")
req.Header.Set("x-on-behalf-of", "$MEMBER_ID")
req.Header.Set("x-idempotency-key", "$IDEMPOTENCY_KEY")
req.Header.Set("content-type", "application/json")
res, err := http.DefaultClient.Do(req)
// 金额字段用 string 接,不要 float64HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.zise.com/v1/shipping-addresses/{id}"))
.header("x-auth-token", "Bearer $TOKEN")
.header("x-on-behalf-of", "$MEMBER_ID")
.header("x-idempotency-key", "$IDEMPOTENCY_KEY")
.header("content-type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString("""
{
"country": "HK",
"recipient_last": "陈",
"recipient_first": "小明",
"phone_code": "852",
"phone_number": "51234567",
"city": "香港",
"line1": "皇后大道中 15 号",
"postal_code": "000000"
}
"""))
.build();
// 金额字段用 String / BigDecimal,不要 double$ch = curl_init('https://api.zise.com/v1/shipping-addresses/{id}');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'x-auth-token: Bearer $TOKEN',
'x-on-behalf-of: $MEMBER_ID',
'x-idempotency-key: $IDEMPOTENCY_KEY',
'content-type: application/json',
],
CURLOPT_POSTFIELDS => <<<'JSON'
{
"country": "HK",
"recipient_last": "陈",
"recipient_first": "小明",
"phone_code": "852",
"phone_number": "51234567",
"city": "香港",
"line1": "皇后大道中 15 号",
"postal_code": "000000"
}
JSON,
]);
$res = curl_exec($ch);
// 金额用 bcmath / 字符串,不要 floatval
200
// spec 里还没有这个 operation 的响应示例