'issue creating an user with calculated field fastAPI

I have a simple API to insert data inside an object type dictionary, my issue is when I try to save a calculated field. Example code:

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

users = {}
class User(BaseModel):
    name: str
    email: str
    calculated: float

@app.post('/user-create/{id_user}')
def creating_an_user(id_user:int,user:User):

    calculated = 1+2+3*2

    if id_user in users:
        return {"Error":"User ID already exists."}

    users[id_user] = {
        "name":user.name,
        "email":user.email,
        "calculated":user.calculated #should I need to put just like that ?
    }

    return users[id_user]

Obviously I receive an error, I think because my method is waiting a manually insert "calculated" field but is not: TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

I am lost in this concern, can anybody help me on this?



Sources

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

Source: Stack Overflow

Solution Source