Zum Inhalt springen

OTOBO API TypeScript Beispiele

Die OTOBO API aus TypeScript mit fetch aufrufen. Es gibt kein npm-Paket für diese API. Die Beispiele sind der ganze Client: ein Bearer-Token und JSON.

Ersetzen Sie YOUR_TOKEN durch ein Token aus Admin → API oder durch das persönliche API-Token eines Agenten. Die Basis-URL auf diesem OTOBO-System ist https://helpdesk.example.com/otobo/otai-api.pl/v1. Ablauf und Rechte stehen auf der Seite Authentifizierung.

Felder und Fehler: Tickets.

const payload = {
"title": "Printer offline",
"queue": "Service Desk",
"state": "new",
"priority": "3 normal",
"customerUser": "max@example.com",
"article": {
"subject": "Printer offline",
"body": "Floor 2, the device shows no paper path.",
"mimeType": "text/plain"
}
};
const response = await fetch("https://helpdesk.example.com/otobo/otai-api.pl/v1/tickets", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_TOKEN",
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());

Felder und Fehler: FAQ.

const response = await fetch("https://helpdesk.example.com/otobo/otai-api.pl/v1/faqs?query=vpn&limit=20", {
method: "GET",
headers: {
Authorization: "Bearer YOUR_TOKEN",
Accept: "application/json",
},
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());

Felder und Fehler: Queues.

const response = await fetch("https://helpdesk.example.com/otobo/otai-api.pl/v1/queues", {
method: "GET",
headers: {
Authorization: "Bearer YOUR_TOKEN",
Accept: "application/json",
},
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());

Felder und Fehler: Agents.

const response = await fetch("https://helpdesk.example.com/otobo/otai-api.pl/v1/agents", {
method: "GET",
headers: {
Authorization: "Bearer YOUR_TOKEN",
Accept: "application/json",
},
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());

Felder und Fehler: Customer users.

const response = await fetch("https://helpdesk.example.com/otobo/otai-api.pl/v1/customer-users?search=max@example.com", {
method: "GET",
headers: {
Authorization: "Bearer YOUR_TOKEN",
Accept: "application/json",
},
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());

Häufig gestellte Fragen

Brauche ich ein TypeScript-SDK für die OTOBO API?

Nein. Die Beispiele senden HTTP mit einem Bearer-Token. Es gibt kein Paket, das Sie veröffentlichen oder aktualisieren müssen.

Die OTOBO API aus TypeScript mit fetch aufrufen. Es gibt kein npm-Paket für diese API. Die Beispiele sind der ganze Client: ein Bearer-Token und JSON.

Quellen

Wohin sende ich das Token?

In den Header Authorization: Bearer. Die Basis-URL endet auf /otai-api.pl/v1.

Quellen

Workflows und Schnittstellen

Webservices, Prozesse und Anbindungen, die zu Ihrer Landschaft passen.