API Testing and Debugging Template
Before making requests, define your OAuth token or Bearer token.
Use this step only if your API requires OAuth 2.0 client credentials flow.
const authResponse = await fetch("https://auth.example.com/token", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "client_credentials",
client_id: "your_client_id",
client_secret: "your_client_secret"
})
});
const { access_token } = await authResponse.json();
console.log("OAuth Token:", access_token);
Set your API base URL and token (replace with your actual values).
const baseURL = "https://api.example.com";
const token = "your_api_token_here"; // Replace with OAuth token if using OAuth
Retrieve user information.
const response = await fetch(`${baseURL}/users`, {
method: "GET",
headers: { "Authorization": `Bearer ${token}` }
});
console.log(await response.json());
Create a new user in the system.
const response = await fetch(`${baseURL}/users`, {
method: "POST",
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}` },
body: JSON.stringify({ name: "John Doe", email: "john@example.com" })
});
console.log(await response.json());
Modify an existing user by ID.
const response = await fetch(`${baseURL}/users/123`, {
method: "PUT",
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}` },
body: JSON.stringify({ name: "Jane Doe" })
});
console.log(await response.json());
Delete a user from the system.
const response = await fetch(`${baseURL}/users/123`, {
method: "DELETE",
headers: { "Authorization": `Bearer ${token}` }
});
console.log(await response.json());
❓ Issue with the request? Ask Znote AI:
"Why is my API call failing?"
💡 Pro Tips:
"Accept": "application/json"
.🚀 Test instantly within Znote—no need for Postman!