Invalid file format when uploading prettified JSON file

When trying to use the JSON file with the content below I get the invalid file format error using NodeJS library. But the same file uploads well if I remove all formatting.

let newFileID = await openai.files.create({
                file: fs.createReadStream(element),
                purpose: "assistants",
            });
Error: 400 Invalid file format. Supported formats: "c", "cpp", "css", "csv", "docx", "gif", "html", "java", "jpeg", "jpg", "js", "json", "md", "pdf", "php", "png", "pptx", "py", "rb", "tar", "tex", "ts", "txt", "xlsx", "xml", "zip" Stack: Error: 400 Invalid file format. Supported formats: "c", "cpp", "css", "csv", "docx", "gif", "html", "java", "jpeg", "jpg", "js", "json", "md", "pdf", "php", "png", "pptx", "py", "rb", "tar", "tex", "ts", "txt", "xlsx", "xml", "zip"
    at APIError.generate (C:\MyStuff\Work\projects\dso-research\src\openai\tests\node_modules\openai\error.js:44:20)
    at OpenAI.makeStatusError (C:\MyStuff\Work\projects\dso-research\src\openai\tests\node_modules\openai\core.js:263:33)
    at OpenAI.makeRequest (C:\MyStuff\Work\projects\dso-research\src\openai\tests\node_modules\openai\core.js:306:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[
    {
        "name": "Guacamole",
        "title": "Classic Guacamole",
        "documenttype": "recipe",
        "usage": [
            "dip"
        ],
        "categories": {
            "dietary": [
                "vegetarian",
                "gluten-free"
            ],
            "agegroup": [
                "adults",
                "all ages"
            ],
            "location": [
                "indoor",
                "outdoor"
            ],
            "atmosphere": [
                "casual",
                "social"
            ],
            "occasion": [
                "barbecue party",
                "party with friends",
                "celebration"
            ],
            "cuisine": [
                "Mexican"
            ]
        },
        "ingredients": [
            "Avocado",
            "Lime",
            "Tomato",
            "Onion",
            "Cilantro",
            "Salt",
            "Pepper"
        ],
        "shoppinglist": [
            "Avocado",
            "Lime",
            "Tomato",
            "Onion",
            "Cilantro",
            "Salt",
            "Pepper"
        ]
    },
    {
        "name": "Caprese Skewers",
        "title": "Caprese Skewers with Balsamic Glaze",
        "documenttype": "recipe",
        "usage": [
            "meal",
            "appetizer"
        ],
        "categories": {
            "dietary": [
                "vegetarian",
                "gluten-free"
            ],
            "agegroup": [
                "adults",
                "all ages"
            ],
            "location": [
                "indoor",
                "outdoor"
            ],
            "atmosphere": [
                "casual",
                "formal"
            ],
            "occasion": [
                "party with friends",
                "celebration"
            ],
            "cuisine": [
                "Italian"
            ]
        },
        "ingredients": [
            "Cherry Tomatoes",
            "Fresh Mozzarella Balls",
            "Fresh Basil Leaves",
            "Balsamic Glaze",
            "Salt",
            "Pepper"
        ],
        "shoppinglist": [
            "Cherry Tomatoes",
            "Fresh Mozzarella Balls",
            "Fresh Basil Leaves",
            "Balsamic Glaze",
            "Salt",
            "Pepper"
        ]
    }
]
1 Like