Skip to content

Request Body missing filed #5884

@Temimal

Description

@Temimal

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

class NotificationGroupBase(BaseModel):
    id: Optional[int]
    name: str
    owner: str
    create_time: Optional[str]
    update_time: Optional[str]
    class Config:
        orm_mode = True
        schema_extra = {
            "example": {
                id: 1,
                "name": "SRE_Notification_Group",
                "owner": "test@trendmicro.com",
                "create_time": "1234567890123",
                "update_time": "1234567890123"
            }
        }

# end class
@router.post("/")
async def add_notification_group(notification_group: NotificationGroupBase, trace: UUID = Header(...), db: Session = Depends(get_db)):
    logger.info(
        f'{notification_group.owner} adds new notification group, group name is {notification_group.name}. trace id: {trace}')
    notification_group_model = models.NotificationGroup()
    notification_group_model.email = notification_group.name
    notification_group_model.username = notification_group.owner
    notification_group_model.create_time = round(time.time() * 1000)

    db.add(notification_group_model)
    db.commit()
    logger.info(f'added {notification_group.name} done. trace id: {trace}')
# end def

Description

2 validation errors for Request
body -> name
field required (type=value_error.missing)
body -> owner
field required (type=value_error.missing)

Operating System

Windows

Operating System Details

windows 10

FastAPI Version

0.88.0

Python Version

Python 3.8.3

Additional Context

2 validation errors for Request
body -> name
field required (type=value_error.missing)
body -> owner
field required (type=value_error.missing)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions