title: HTTPS POST to query FastAPI using python requests
body: <p>I am trying to serve a Neural Network using FastAPI.</p>
  <pre><code>from fastapi import Depends, FastAPI
  from pydantic import BaseModel
  from typing import Dict
  
  class iRequest(BaseModel):
      arg1: str
      arg2: str
  
  class iResponse(BaseModel):
      pred: str
      probs: Dict[str, float]
  
  @app.post(&quot;/predict&quot;, response_model=iResponse)
  def predict(request: iRequest, model: Model = Depends(get_model)):
      pred, probs = model.predict(request.arg1, request.arg2)
      return iResponse(pred = pred, probs = probs)
  </code></pre>
  <p>The manual site http://localhost:8000/docs#/default/predict_predict_post works fine and translates into the following curl command:</p>
  <pre><code>curl -X POST &quot;http://localhost:8000/predict&quot; -H  &quot;accept: application/json&quot; -H  &quot;Content-Type: application/json&quot; -d &quot;{\&quot;arg1\&quot;:\&quot;I am the King\&quot;,\&quot;arg2\&quot;:\&quot;You are not my King\&quot;}&quot;
  </code></pre>
  <p>which also works.
  When I try to query the API using python requests:</p>
  <pre><code>import requests
  data = {&quot;arg1&quot;: &quot;I am the King&quot;,
          &quot;arg2&quot;: &quot;You are not my King&quot;}
  r = requests.post(&quot;http://localhost:8000/predict&quot;, data=data)
  </code></pre>
  <p>I only get the &quot;422 Unprocessable Entity&quot; Errors. Where am I going wrong here?</p>