> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Why do I get HTML responses instead of JSON from the Admin API?



The [Admin API](admin_api) requires authentication using your API Key and API Secret. When authentication fails, you may receive unexpected responses that can be confusing to debug.

## The problem

When your Admin API call returns HTML content instead of the expected JSON response, this typically indicates an authentication problem.

**Expected JSON response:**

```json
{
  "resources": [
    {
      "public_id": "sample",
      "format": "jpg",
      "version": 1234567890,
      "resource_type": "image",
      "type": "upload",
      "created_at": "2023-01-15T10:30:00Z",
      "bytes": 120000,
      "width": 800,
      "height": 600,
      "url": "https://res.cloudinary.com/demo/image/upload/v1234567890/sample.jpg"
    }
  ],
  "next_cursor": null
}
```

**HTML error response (authentication failure):**

```html
<html>
  <head>
    <title>401 Authorization Required</title>
  </head>
  <body>
    <h1>Authorization Required</h1>
    <p>This server could not verify that you are authorized to access...</p>
  </body>
</html>
```

## Common causes

### Missing credentials

Your API Key and API Secret aren't included in the request, or are in the wrong format.

**Incorrect - missing credentials:**

```bash
curl https://api.cloudinary.com/v1_1/demo/resources/image
```

**Correct - credentials included:**

```bash
curl https://123456789012345:abcdefghijklmnopqrstuvwxyz123456@api.cloudinary.com/v1_1/demo/resources/image
```

### Incorrect Base64 encoding

When manually creating Authorization headers, ensure proper Base64 encoding of `api_key:api_secret`.

**Incorrect - wrong encoding:**

```bash
curl -H "Authorization: Basic 123456789012345:abcdefghijklmnopqrstuvwxyz123456" \
     https://api.cloudinary.com/v1_1/demo/resources/image
```

**Correct - proper Base64 encoding:**

```bash
curl -H "Authorization: Basic MTIzNDU2Nzg5MDEyMzQ1OmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MTIzNDU2" \
     https://api.cloudinary.com/v1_1/demo/resources/image
```

### Wrong API Key or Secret

Double-check your credentials in the [Console Settings](https://console.cloudinary.com/app/settings/api-keys).

## The solution

### Step 1: Verify your credentials

Ensure you're using the correct API Key and API Secret from the [API Keys](https://console.cloudinary.com/app/settings/api-keys) page of the Console Settings.

### Step 2: Choose the correct authentication method

#### Method 1: URL authentication (recommended for cURL)

Include credentials directly in the URL:

```bash
curl https://<API_KEY>:<API_SECRET>@api.cloudinary.com/v1_1/<CLOUD_NAME>/resources/image
```

#### Method 2: Authorization header

Encode your API key and API secret as a Base64 string in the format:

```text
<API_KEY>:<API_SECRET>
```

Then include the encoded value in the `Authorization` header using the `Basic` scheme:

```bash
# Create the credential string
CREDENTIALS="<API_KEY>:<API_SECRET>"

# Base64 encode the credentials
ENCODED=$(echo -n "$CREDENTIALS" | base64)

# Use in Authorization header
curl -H "Authorization: Basic $ENCODED" \
     https://api.cloudinary.com/v1_1/<CLOUD_NAME>/resources/image
```

**Example**

```bash
# Example credentials
API_KEY="123456789012345"
API_SECRET="abcdefghijklmnopqrstuvwxyz123456"

# Combine credentials
COMBINED="${API_KEY}:${API_SECRET}"
# Result: "123456789012345:abcdefghijklmnopqrstuvwxyz123456"

# Base64 encode
echo -n "$COMBINED" | base64
# Result: MTIzNDU2Nzg5MDEyMzQ1OmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MTIzNDU2

# Use in request
curl -H "Authorization: Basic MTIzNDU2Nzg5MDEyMzQ1OmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MTIzNDU2" \
     https://api.cloudinary.com/v1_1/demo/resources/image
```

## Using SDKs (recommended)

The easiest way to avoid authentication issues is to use one of Cloudinary's [official SDKs](cloudinary_sdks), which handle authentication automatically:

```multi
|nodejs
// Authentication handled automatically
cloudinary.v2.api.resources()
  .then(result => console.log(result));

|python
# Authentication handled automatically
result = cloudinary.api.resources()

|ruby
# Authentication handled automatically
result = Cloudinary::Api.resources

|go
// Authentication handled automatically
resp, err := cld.Admin.Assets(ctx, admin.AssetsParams{})

|php_2
// Authentication handled automatically
$result = $api->assets();

|java
// Authentication handled automatically
ApiResponse result = api.resources(ObjectUtils.emptyMap());

|csharp
// Authentication handled automatically
var result = cloudinary.ListResources();
```

> **NOTE**: SDKs automatically handle the proper formatting and encoding of your credentials, eliminating most authentication issues.

> **READING**:
>
> * [Admin API](admin_api)

> * [Cloudinary SDKs](cloudinary_sdks)