I have a simple Fastapi where am expecting python dictionary or json data.
I can POST and GET data when running on local server. I hosted same api on https://deta.sh but i can only send GET request. POST request is returning status code 500
.
I tried hosting the same api on Heroku but i get status code 503
here is the sample code:
models.py
class DictType(TypeDecorator):
impl = Text(SIZE)
def process_bind_param(self, value, dialect):
if value is not None:
value = json.dumps(value)
return value
def process_result_value(self, value, dialect):
if value is not None:
value = json.dumps(value)
return value
class DictTransactionBase(Base):
__tablename__ = "Transactions"
id = Column(Integer, primary_key=True, index=True)
Body = Column(DictType())
schemas.py
class DictTransactionModel(BaseModel):
Body: dict = {}
class Config:
orm_mode = True
main.py
@app.post('/api/v1/send/transactions/', status_code=status.HTTP_201_CREATED)
async def create_transaction(trans: schema.DictTransactionModel, db: Session = Depends(get_db)):
results = models.DictTransactionBase(**trans.dict())
db.add(results)
db.commit()
db.refresh(results)
return results
Above code runs on a local machine and POST data is saved to SQLite database. What would be the reason POST request is failing on the deployed API.