Reputation: 61
The request for an ID does return a record correctly, but the URL has the record being searched in front of a "/" in the address bar:
http://fastapi.localhost:8008/person/2
Below is my request paramter for a GET request:
@app.get("/person/{id}", tags=["API Endpoint"])
async def get_persons(id: int | None = None, person: str | None = None, yesno: str | None = None):
id_list = await Person.objects.get(pk=id)
return id_list
And the response_model is structured as follows:
class Person(ormar.Model):
class Meta(BaseMeta):
tablename = str = "persons"
id: int = ormar.Integer(primary_key=True)
person: str = ormar.String(max_length=250, nullable=True)
yesno: str = ormar.String(max_length=4, nullable=True)
Ideally, the URL would have the equal sign:
http://fastapi.localhost:8008/person=2
Please let me know if there's any additional information I can provide and thank you in advance.
Upvotes: 0
Views: 46