# 'file' is a required property Error

**URL:** <https://community.openai.com/t/file-is-a-required-property-error/731496>\
**Category:** API\
**Created:** [April 29, 2024, 5:59pm UTC](https://community.openai.com/t/file-is-a-required-property-error/731496 "2024-04-29T17:59:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev.evanpiro](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/dev.evanpiro/32/148452_2.png) [@dev.evanpiro](https://community.openai.com/u/dev.evanpiro)\
**Post date:** [April 29, 2024, 5:59pm UTC](https://community.openai.com/t/file-is-a-required-property-error/731496/1 "2024-04-29T17:59:04Z")

</div>

I’m getting a “‘file’ is a required property” error when trying to create a file. After looking at several posts that seem to have have resolved it, I’m still getting the same error.

Here is the error:

```auto
{
  error: {
    message: "'file' is a required property",
    type: 'invalid_request_error',
    param: null,
    code: null
  }
}

```

Here is the code.

```auto
const formData = new FormData();
    let file = new Blob(["a string"], {
      type: "text/plain; charset=utf8",
});

formData.append("purpose", "fine-tune");
formData.append("file", file, "file.jsonl");

// Define the endpoint URL for creating files in OpenAI
const url = "https://api.openai.com/v1/files";

// Define the options for the fetch request, including method, headers, and body
const fetchOptions: RequestInit = {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
  },
  body: formData,
};

// Make the POST request to OpenAI
const response = await fetch(url, fetchOptions);

```
