Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

573
Vistas
fastapi get header parameter is none in basemodel use Header cant get token but in function its ok why?

in basemodel use Header cant get token but in function its ok why?

   class Test(BaseModel):
        name: str
        token: str= Header(None)

def login(t: Test):
    print(t.dict())
    return 'test'

output  {'name': '123', 'token': None} 

if i do this is ok

def login(t: Test,token: str= Header(None)):
        print(t.dict(),token)
        return 'test'
    
    output  {'name': '123', 'token': None} 123456

who can help me plz !

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The Pydantic model here represents the validation of the request payload.

The values mentioned in the "Test" model should be available in request payload. Since the header is not the payload, we cannot use that in Basemodel.

Yet you can use that in api function. When you call the api, then the request params can be used in the function. So, it is possible to use this

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda