Documentation / Requests

Request Formatting

How to properly format API requests

Request Formatting

Learn how to properly format requests to the WebinOne API, including headers, content types, and body formats.

Content-Type Requirements

Different endpoints require different content types:

OAuth Token Request

Must use multipart/form-data:

Content-Type: multipart/form-data

Module Items (POST/PUT)

Must use application/x-www-form-urlencoded:

Content-Type: application/x-www-form-urlencoded

Other Admin Endpoints

Most other endpoints accept application/json:

Content-Type: application/json

Required Headers

All authenticated requests must include:

  • Authorization: Bearer token from OAuth
  • Content-Type: Appropriate for the endpoint

URL Parameters

Query parameters must be properly URL-encoded:

// WHERE clause must be JSON-encoded
const where = {"$and": [{"$eq": {"Enabled": true}}]};
const encoded = encodeURIComponent(JSON.stringify(where));
const url = `/api/v2/admin/pages?Where=${encoded}`;

Request Body Formats

Form Data (Module Items)

Name=Page%20Title&UrlSlug=page-slug&Enabled=true

JSON (Most Endpoints)

{
  "Name": "Snippet Name",
  "Alias": "snippet_alias",
  "Content": "
Content
", "Enabled": true }

⚠️ Common Mistake

Using the wrong Content-Type will result in 400 Bad Request errors or data not being parsed correctly.

Code Examples

// JavaScript: Form Data Request
const createPage = async (token) => {
  const formData = new URLSearchParams();
  formData.append('ModuleId', '1522');
  formData.append('Name', 'My Page');
  formData.append('UrlSlug', 'my-page');
  formData.append('Enabled', 'true');
  formData.append('ReleaseDate', '2026-07-07T00:00:00');
  formData.append('ExpiryDate', '2099-12-31T00:00:00');
  
  const response = await fetch('https://your-site.webinone.com/api/v2/admin/module-items', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: formData.toString()
  });
  
  return await response.json();
};

// JavaScript: JSON Request
const createSnippet = async (token) => {
  const response = await fetch('https://your-site.webinone.com/api/v2/admin/snippets', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      Name: 'Header',
      Alias: 'header',
      Content: '
...
', Enabled: true }) }); return await response.json(); };