zappfinger
zappfinger

Reputation: 587

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'?

Upvotes: 25

Views: 53153

Answers (2)

zappfinger
zappfinger

Reputation: 587

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

Removing that solved the problem.

Upvotes: 9

javaNoob2792
javaNoob2792

Reputation: 89

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.

Upvotes: 3

Related Questions