'FastApi returns "field required" and "value_error.missing" for one of my parameters, but the field is there

I do a Post with some parameters, but one of them returns "field required" and "value_error.missing", but the field is there and it has a value. See the output of Postman. field "body" is not missing

In schemas.py the fields are defined as follows:

class Message(BaseModel):
    title: str
    id: int
    datim: Optional[datetime]
    to_id: Optional[int]
    from_id: Optional[int]
    body: Optional[str]

    class Config:
        orm_mode = True

So why does it complain about 'body'?



Solution 1:[1]

It turned out I had an extra argument in my function for @app.post() that was not used. Removing that solved the problem!

Solution 2:[2]

This is for anyone who still has issues with this, I had a one to one relationship but had not specified uselist=False while defining the relationship. Hope this helps :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zappfinger
Solution 2 javaNoob2792