Zum Inhalt

Senden der Bestandsaktualisierung

Um eine Bestands-/Preisaktualisierung zu senden, wird der folgende Endpunkt verwendet. Die Bestandsaktualisierung muss regelmäßig an diesen Endpunkt gesendet werden:

https://merchants-connector-importer.zalandoapis.com/{Client ID}/{Stock File Name}

HTTP-Anfrage

  • PUT-Methode

URL Parameters and Header

Parameter Type Example
Client ID String d329krpq
Stock File Name CSV 20181023_update.csv
API Key (x-api-key) String lXViWTzFic9sM8Qqe9Ew7JME8xTdBAOMJHdIjK7XkjQ00OWr

Anforderungen (ZWINGEND ERFORDRLICH)

The request

  • Must be an HTTP PUT request.
  • Must contain the Client ID in the URL request ({Client ID} would be replaced). Example: d329krpq.
  • Must contain the stock file name that will be received ({Stock File Name} would be replaced), which can be different from your local file name. Example: 20181023_update.csv
  • Must include the stock CSV file.
  • Must contain the API Key in the headers (header name: x-api-key). Example: lXViWTzFic9sM8Qqe9Ew7JME8xTdBAOMJHdIjK7XkjQ00OWr.

Stores in multiple countries

Wenn Kunden in mehreren Ländern tätig sind, hat jedes Land einen separaten API-Schlüssel und eine separate Kunden-ID und es sind separate Bestands-Feeds für jedes Land erforderlich.

Code-Beispiele

Shell

curl -v -X PUT https://merchants-connector-importer.zalandoapis.com/d329krpq/20181023_update.csv 
--upload-file 20181023_update.csv 
--header "x-api-key: lXViWTzFic9sM8Qqe9Ew7JME8xTdBAOMJHdIjK7XkjQ00OWr"

Powershell

Invoke-WebRequest `
-UseBasicParsing `
-Uri https://merchants-connector-importer.zalandoapis.com/d329krpq/20181023_update.csv  `
-Method PUT `
-InFile 20181023_update.csv `
-Headers @{'x-api-key'='lXViWTzFic9sM8Qqe9Ew7JME8xTdBAOMJHdIjK7XkjQ00OWr'}

Python

import requests

client_id = "d329krpq"

headers = {
    'x-api-key': "lXViWTzFic9sM8Qqe9Ew7JME8xTdBAOMJHdIjK7XkjQ00OWr",
    'content-type': "application/csv",
    'cache-control': "no-cache"
}

with open('feed_data.csv', 'rb') as f:
    res = requests.put(f"https://merchants-connector-importer.zalandoapis.com/{client_id}/20181023_update.csv".format(client_id=client_id), headers=headers, data=f.read())

    if res.status_code == 200:
        print("Success")
    else:
        print("Failed")

Nodejs

const axios = require('axios')
const fs = require('fs')

const clientId = "d329krpq"
const apiKey = "lXViWTzFic9sM8Qqe9Ew7JME8xTdBAOMJHdIjK7XkjQ00OWr"
const fileName = "file.csv"
const data = fs.createReadStream(fileName)
const url = `https://merchants-connector-importer.zalandoapis.com/${clientId}/${fileName}`

const config = {
    headers: {
        "content-type": "application/csv",
        "x-api-key": apiKey,
        "cache-control": "no-cache"
    }
}

axios.put(url, data, config)
    .then((response) => {
        // handle success
        console.log(response);
    })
    .catch((error) => {
        // handle error
        console.log(error);
    })

Response

Response status of 200 (OK)

Wenn der Datei-Upload erfolgreich ist, lautet der Antwortstatus 200 (OK). Ein Backend-Prozess wird dann die Aufgabe in Kürze übernehmen und die Updates durchführen, wenn das Dateiformat und die Kodierung korrekt sind.