更新批次元数据
curl --request PATCH \
--url https://api.olostep.com/v1/batches/{batch_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"metadata": {
"status": "reviewed",
"reviewer": "jane@example.com"
}
}
'import requests
url = "https://api.olostep.com/v1/batches/{batch_id}"
payload = { "metadata": {
"status": "reviewed",
"reviewer": "jane@example.com"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({metadata: {status: 'reviewed', reviewer: 'jane@example.com'}})
};
fetch('https://api.olostep.com/v1/batches/{batch_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.olostep.com/v1/batches/{batch_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'metadata' => [
'status' => 'reviewed',
'reviewer' => 'jane@example.com'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.olostep.com/v1/batches/{batch_id}"
payload := strings.NewReader("{\n \"metadata\": {\n \"status\": \"reviewed\",\n \"reviewer\": \"jane@example.com\"\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.olostep.com/v1/batches/{batch_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"status\": \"reviewed\",\n \"reviewer\": \"jane@example.com\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.olostep.com/v1/batches/{batch_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {\n \"status\": \"reviewed\",\n \"reviewer\": \"jane@example.com\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "batch_abc123def456",
"object": "batch",
"status": "completed",
"created": 1704067200,
"total_urls": 10,
"completed_urls": 10,
"metadata": {
"batch_name": "Q1 Product Sync",
"status": "reviewed",
"reviewer": "jane@example.com"
}
}{
"id": "error_abc123",
"object": "error",
"code": "invalid_metadata",
"type": "https://docs.olostep.com/api-reference/errors/bad_request",
"status": 400,
"title": "错误请求",
"detail": "No metadata field provided. Only metadata can be updated.",
"created": 1704067200,
"metadata": {}
}{
"id": "error_abc123",
"object": "error",
"code": "invalid_api_key",
"type": "https://docs.olostep.com/api-reference/errors/unauthorized",
"status": 401,
"title": "未授权",
"detail": "Your API key is invalid",
"created": 1704067200,
"metadata": {}
}{
"id": "error_abc123",
"object": "error",
"code": "batch_not_found",
"type": "https://docs.olostep.com/api-reference/errors/not_found",
"status": 404,
"title": "未找到",
"detail": "Batch not found",
"created": 1704067200,
"metadata": {}
}{
"id": "error_abc123",
"object": "error",
"code": "internal_server_error",
"type": "https://docs.olostep.com/api-reference/errors/internal_error",
"status": 500,
"title": "内部服务器错误",
"detail": "An unexpected error occurred",
"created": 1704067200,
"metadata": {}
}批次
更新批次
更新特定批次的元数据。批次创建后只能更新元数据。
PATCH
/
v1
/
batches
/
{batch_id}
更新批次元数据
curl --request PATCH \
--url https://api.olostep.com/v1/batches/{batch_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"metadata": {
"status": "reviewed",
"reviewer": "jane@example.com"
}
}
'import requests
url = "https://api.olostep.com/v1/batches/{batch_id}"
payload = { "metadata": {
"status": "reviewed",
"reviewer": "jane@example.com"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({metadata: {status: 'reviewed', reviewer: 'jane@example.com'}})
};
fetch('https://api.olostep.com/v1/batches/{batch_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.olostep.com/v1/batches/{batch_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'metadata' => [
'status' => 'reviewed',
'reviewer' => 'jane@example.com'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.olostep.com/v1/batches/{batch_id}"
payload := strings.NewReader("{\n \"metadata\": {\n \"status\": \"reviewed\",\n \"reviewer\": \"jane@example.com\"\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.olostep.com/v1/batches/{batch_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"status\": \"reviewed\",\n \"reviewer\": \"jane@example.com\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.olostep.com/v1/batches/{batch_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {\n \"status\": \"reviewed\",\n \"reviewer\": \"jane@example.com\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "batch_abc123def456",
"object": "batch",
"status": "completed",
"created": 1704067200,
"total_urls": 10,
"completed_urls": 10,
"metadata": {
"batch_name": "Q1 Product Sync",
"status": "reviewed",
"reviewer": "jane@example.com"
}
}{
"id": "error_abc123",
"object": "error",
"code": "invalid_metadata",
"type": "https://docs.olostep.com/api-reference/errors/bad_request",
"status": 400,
"title": "错误请求",
"detail": "No metadata field provided. Only metadata can be updated.",
"created": 1704067200,
"metadata": {}
}{
"id": "error_abc123",
"object": "error",
"code": "invalid_api_key",
"type": "https://docs.olostep.com/api-reference/errors/unauthorized",
"status": 401,
"title": "未授权",
"detail": "Your API key is invalid",
"created": 1704067200,
"metadata": {}
}{
"id": "error_abc123",
"object": "error",
"code": "batch_not_found",
"type": "https://docs.olostep.com/api-reference/errors/not_found",
"status": 404,
"title": "未找到",
"detail": "Batch not found",
"created": 1704067200,
"metadata": {}
}{
"id": "error_abc123",
"object": "error",
"code": "internal_server_error",
"type": "https://docs.olostep.com/api-reference/errors/internal_error",
"status": 500,
"title": "内部服务器错误",
"detail": "An unexpected error occurred",
"created": 1704067200,
"metadata": {}
}合并语义: 元数据更新遵循Stripe的方法——新键会被添加,现有键会被更新,设置为空字符串
"" 的键会被删除。授权
Bearer认证头格式为Bearer ,其中是你的认证令牌。
路径参数
要更新的批次ID。
请求体
application/json
用于存储对象附加信息的键值对集合。遵循Stripe的验证规则:最多50个键,键最多40个字符(不含方括号),值最多500个字符,所有值以字符串形式存储。
Show child attributes
Show child attributes
示例:
{
"order_id": "12345",
"customer_name": "John Doe",
"priority": "high",
"processed": "true"
}
响应
批次元数据更新成功。
批处理 ID
对象的类型。此端点为 "batch"。
in_progress 或 completed
创建的纪元时间
批处理中 URL 的数量
已完成的 URL 数量
用于存储对象附加信息的键值对集合。遵循Stripe的验证规则:最多50个键,键最多40个字符(不含方括号),值最多500个字符,所有值以字符串形式存储。
Show child attributes
Show child attributes
示例:
{
"order_id": "12345",
"customer_name": "John Doe",
"priority": "high",
"processed": "true"
}
此页面对您有帮助吗?
⌘I