Vai al contenuto principale
PATCH
/
v1
/
batches
/
{batch_id}
Aggiorna i metadati del batch
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": "Richiesta Errata",
"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": "Non autorizzato",
"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": "Non Trovato",
"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": "Errore Interno del Server",
"detail": "An unexpected error occurred",
"created": 1704067200,
"metadata": {}
}
Semantica di unione: Gli aggiornamenti dei metadati seguono l’approccio di Stripe — le nuove chiavi vengono aggiunte, le chiavi esistenti vengono aggiornate e le chiavi impostate su stringa vuota "" vengono eliminate.

Autorizzazioni

Authorization
string
header
obbligatorio

Intestazione di autenticazione Bearer del tipo Bearer , dove è il tuo token di autenticazione.

Parametri del percorso

batch_id
string
obbligatorio

L'ID del batch da aggiornare.

Corpo

application/json
metadata
object
obbligatorio

Insieme di coppie chiave-valore per memorizzare informazioni aggiuntive su un oggetto. Segue l'approccio di Stripe con regole di validazione: massimo 50 chiavi, chiave massimo 40 caratteri (senza parentesi quadre), valore massimo 500 caratteri, tutti i valori memorizzati come stringhe.

Esempio:
{
"order_id": "12345",
"customer_name": "John Doe",
"priority": "high",
"processed": "true"
}

Risposta

Metadati del batch aggiornati con successo.

id
string

ID del Batch

object
string

Il tipo di oggetto. "batch" per questo endpoint.

status
string

in_progress o completed

created
number

Epoch creato

total_urls
number

Conteggio degli URL nel batch

completed_urls
number

Conteggio degli URL completati

metadata
object

Insieme di coppie chiave-valore per memorizzare informazioni aggiuntive su un oggetto. Segue l'approccio di Stripe con regole di validazione: massimo 50 chiavi, chiave massimo 40 caratteri (senza parentesi quadre), valore massimo 500 caratteri, tutti i valori memorizzati come stringhe.

Esempio:
{
"order_id": "12345",
"customer_name": "John Doe",
"priority": "high",
"processed": "true"
}