Bad request - Only photo or video can be accepted as media type

Hi everyone,

I’m building an auto-posting workflow for Instagram using Google Drive and the Facebook Graph API in n8n, but I’ve run into an error I can’t solve.

My current setup:

  1. Google Drive node retrieves the image file (URL + metadata).
  2. Facebook (Create Container) node tries to post the image to Instagram using image_url and a caption.

Error I get:

Bad request - please check your parameters
Only photo or video can be accepted as media type.

It seems the Facebook node isn’t recognizing my Google Drive link as a valid media file.

What I’d like to know:

  • How can I adjust the Facebook node so the container can download the image properly?
  • Should I change my Google Drive link to a direct image file?
  • Or is it better to skip the URL entirely and upload the image as a binary file from n8n?

If you have a better approach for setting up an Instagram auto-posting workflow, I’d really appreciate any suggestions or examples.

Thanks in advance!


{
  "name": "My workflow 4",
  "nodes": [
    {
      "parameters": {
        "content": "https://www.youtube.com/watch?v=n0KDfcvZzOk"
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -384,
        -80
      ],
      "id": "4100474f-9d48-4319-a5b2-2a0b1527a788",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "=https://drive.google.com/drive/u/0/folders/1eHPpmR5lsCVP6EvPP-bjneb-gHepFNJ2",
          "mode": "url"
        },
        "event": "fileCreated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "1f6507f9-0944-472d-a1e3-9497226ccbbf",
      "name": "Google Drive Trigger",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "MiydOD1qFDQCYNvU",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        208,
        0
      ],
      "id": "8906b92b-f4a5-4815-925c-132be288558a",
      "name": "Download file",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "MiydOD1qFDQCYNvU",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "text": "=You are skilled at closely analyzing a single image and crafting a detailed caption based on what you see. Describe the main subject, colors, mood, and any interesting details that stand out. Write a clear, engaging caption that helps viewers understand and appreciate the image without using technical or \"artsy\" language. Make it relatable and suitable for an Instagram audience, encouraging people to connect with the image and respond in the comments. The caption should be vivid, straightforward, and stand on its own as a description of the image, capturing its essence in a way that feels authentic and inviting. Do not use emojis. Do not add hashtags. Do not add quotes. Use fewer adjectives.\n\nSCENARIO: I operate an online store specializing in premium iPhone accessories, including iPhone cases, trendy puffer cases, and stylish crossbody cord straps. My target audience consists of teenagers, students, streetwear enthusiasts, and fashion-forward individuals who value lifestyle aesthetics and functionality in their iPhone accessories.\nMy mission is to create high-quality, engaging, and SEO-optimized blog content that combines: The latest trends in iPhone cases and accessories ,Streetwear and modern fashion influences and Practical style tips for everyday use\n",
        "inputType": "base64",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        416,
        0
      ],
      "id": "b7a9f934-d35e-4122-be5c-dd60ab44a128",
      "name": "Analyze image",
      "credentials": {
        "openAiApi": {
          "id": "ORaQ1sh0xMb69Osb",
          "name": "OpenAI Demo"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1TlFz9iAwWaN_XZ0dC2V1Bnh2AegeEjl3sxkWcAsi6PA",
          "mode": "list",
          "cachedResultName": "Instagram Image Post",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TlFz9iAwWaN_XZ0dC2V1Bnh2AegeEjl3sxkWcAsi6PA/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Blad1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TlFz9iAwWaN_XZ0dC2V1Bnh2AegeEjl3sxkWcAsi6PA/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Caption": "={{ $json.content }}",
            "Name": "={{ $('Download file').item.json.name }}",
            "URL": "={{ $('Google Drive Trigger').item.json.webContentLink }}"
          },
          "matchingColumns": [
            "URL"
          ],
          "schema": [
            {
              "id": "Name",
              "displayName": "Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Caption",
              "displayName": "Caption",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "URL",
              "displayName": "URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        624,
        0
      ],
      "id": "2fc66d53-2f68-49df-b92e-f4b7d947fc18",
      "name": "Append or update row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "cvKto9Qe3xYUFrMC",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "httpRequestMethod": "POST",
        "graphApiVersion": "v22.0",
        "node": "17841471742042867",
        "edge": "media",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "image_url",
                "value": "={{ $json.URL }}"
              },
              {
                "name": "caption",
                "value": "={{ $('Analyze image').item.json.content }}\n\n#AI #Automation #AIAGENT"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.facebookGraphApi",
      "typeVersion": 1,
      "position": [
        832,
        0
      ],
      "id": "f3959d36-1350-4660-8fee-a99633fe6edd",
      "name": "Create container",
      "credentials": {
        "facebookGraphApi": {
          "id": "glENg8IuSrPMh1Bz",
          "name": "Facebook Graph account"
        }
      }
    },
    {
      "parameters": {
        "graphApiVersion": "v22.0",
        "node": "17841471742042867",
        "edge": "media_publish",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "creation_id"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.facebookGraphApi",
      "typeVersion": 1,
      "position": [
        1040,
        0
      ],
      "id": "c8e6cb0c-ddd4-4296-8799-6949c8fe46ce",
      "name": "Post to Instagram",
      "credentials": {
        "facebookGraphApi": {
          "id": "bwmrdffi1havEi38",
          "name": "Facebook Graph account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "Create container",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create container": {
      "main": [
        [
          {
            "node": "Post to Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e6d74fba-0f45-427f-be05-54317f45e702",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "755dc82564fe21ead0c19ed80455b95b52d6de9153bfd26c4c850d1ebd524c4e"
  },
  "id": "gro0CuxLU3I84UNd",
  "tags": []
}```

Hi there, maybe you can use this template as a reference to help you, i think it’s a bit similar and can definitely help to solve your problem

Hi fahmiiireza,

Thanks for reaching out.

Do you know a solution that will make the google docs work?

Hi there @jimvlieger , i might misunderstood you, but google docs? do you mean google sheet? because on the workflow above there r no google docs node

I mean the google sheet :slight_smile:

I tried airtable instead of google docs.. I found a toturial and in that video it works.. But when I copy the settings etc I still receive the same error. Look screens

If anyone knows a good answer please let me know :slight_smile:

Hey n8n community!

I’ve finally found a reliable solution for this challenge: automatically generating an Instagram post with a caption using Airtable and OpenAI. The key was to build a robust workflow that handles image binary data and API calls correctly.

Here are the key steps that worked for me:

  1. Search Records: Use the Airtable node to search for records, making sure to download attachments. This is crucial for handling the image data.

  2. Analyze Image: Instead of a complex HTTP Request, use the pre-built Analyze image node. It’s much simpler and generates the caption text directly.

  3. Create Container: In the Create container node, enable “Send Binary File” and use the variable {{$json.Afbeeldingen[0].binary}} for the image data and {{$json.content}} for the caption. This ensures the image and text are sent together.

  4. Publish Post: The final step is to use the Facebook node with the media_publish edge. Use the Container ID from the previous step to publish the post.

This approach bypasses common issues with URL-based image fetching and ensures a smooth, automated workflow. Hope this helps anyone facing similar problems!