Gibt die Methode und den Inhalt der Anfrage zurück. Akzeptiert JSON, Klartext, einfache Formulardaten und Binärdaten.
Details
Beispielanfragen
POST · JSON
curl 'http://localhost:3000/v1/echo' \
-H 'Content-Type: application/json' \
--data-binary '{"name":"Bob"}'
POST · Klartext
curl 'http://localhost:3000/v1/echo' \
-H 'Content-Type: text/plain' \
--data-binary 'Hello!'
POST · Formular
curl 'http://localhost:3000/v1/echo' \
--data-urlencode 'name=Bob' \
--data-urlencode 'age=42'
POST · Binärdatei
curl 'http://localhost:3000/v1/echo' \
-H 'Content-Type: application/octet-stream' \
--data-binary '@./file.bin'
Antworten
200 OK
Die Methode und der geparste Anfrageinhalt. Dieses Beispiel zeigt eine GET-Anfrage ohne Inhalt.
Beispiel · text/plain
GET
null
Beispiel · application/json
{
"method": "GET",
"body": null
}
Schema · object
| Feld | Typ | Beschreibung |
|---|
methoderforderlich | string | Die HTTP-Methode der Anfrage. |
|---|
bodyerforderlich | object | array | string | number | boolean | null | Ein JSON-Wert, eine Zeichenfolge, Formularfelder oder Binärdaten { encoding: 'base64', sizeBytes: number, data: string }. Ohne Anfrageinhalt: null. |
|---|
body · Binärobjekt
| Feld | Typ | Beschreibung |
|---|
encodingerforderlich | string | Immer "base64". |
|---|
sizeByteserforderlich | integer | Anzahl der ursprünglichen Bytes. |
|---|
dataerforderlich | string | Base64-kodierter Inhalt. |
|---|
400 Bad Request
Ungültiges format, zum Beispiel ?format=xml. Dieser Fehler wird immer als Klartext zurückgegeben.
Beispiel · text/plain
Unsupported format: xml
Valid values: text, json
Beispiel · text/plain
Unsupported format: xml
Valid values: text, json
413 Payload Too Large
Der Anfrageinhalt überschreitet 102.400 Bytes (100 KiB).
Beispiel · text/plain
Request body exceeds the size limit of 100 KiB
Beispiel · application/json
{
"error": "Request body exceeds the size limit of 100 KiB",
"limitBytes": 102400
}
Schema · object
| Feld | Typ | Beschreibung |
|---|
errorerforderlich | string | Fehlerbeschreibung. |
|---|
limitByteserforderlich | integer | Maximale Größe des Anfrageinhalts in Bytes. Wert: 102400. |
|---|
415 Unsupported Media Type
Nicht unterstützter oder fehlender Content-Type bei nicht leerem Anfrageinhalt.
Beispiel · text/plain
Unsupported Content-Type. Supported: application/json, text/plain, application/x-www-form-urlencoded, application/octet-stream
Beispiel · application/json
{
"error": "Unsupported Content-Type. Supported: application/json, text/plain, application/x-www-form-urlencoded, application/octet-stream"
}
Schema · object
| Feld | Typ | Beschreibung |
|---|
errorerforderlich | string | Fehlerbeschreibung. |
|---|
Ungültiges JSON führt ebenfalls zu 400. Bei Syntax- und Kodierungsfehlern des Parsers wird derzeit unabhängig vom Ausgabeformat die Standard-HTML-Antwort von Express verwendet.