title: How to add both file and JSON body in a FastAPI POST request?
body: <p>Specifically, I want the below example to work:</p>
  <pre class="lang-py prettyprint-override"><code>from typing import List
  from pydantic import BaseModel
  from fastapi import FastAPI, UploadFile, File
  
  
  app = FastAPI()
  
  
  class DataConfiguration(BaseModel):
      textColumnNames: List[str]
      idColumn: str
  
  
  @app.post(&quot;/data&quot;)
  async def data(dataConfiguration: DataConfiguration,
                 csvFile: UploadFile = File(...)):
      pass
      # read requested id and text columns from csvFile
  </code></pre>
  <p>If this is not a proper way for a POST request, please advise me how to select required columns from an uploaded CSV file in FastAPI.</p>