0

I am trying to read body from my POST request using FastAPI. However i am not able to understand what (...) argument for the Body function

Here is my code :

@app.post('/createPosts')
def create_post(payload: dict = Body(...)):
    print(payload)
    return {'message': 'succesfully created post'}
Jatin Mehrotra
  • 5,637
  • 1
  • 12
  • 41
  • It's the python built-in constant [`Ellipsis`](https://docs.python.org/3/library/constants.html#Ellipsis). I'm surprised that I can't find a duplicate for this question, maybe someone else can. – myrtlecat Feb 03 '22 at 02:25
  • 1
    Even i couldn't find a duplicate :(, okay its a built-in constant but what is the use of it? it throws error if i omit it – Jatin Mehrotra Feb 03 '22 at 02:27
  • I think [this](https://stackoverflow.com/questions/772124/what-does-the-ellipsis-object-do) might be the aforementioned duplicate, and [this answer](https://stackoverflow.com/a/66666228/16450169) discusses FastAPI specifically – 0x263A Feb 03 '22 at 02:37
  • even though it explain `what` is Ellipsis but it doesnt say `why`? Also it doesnt even mention the context in using with FASTAPI, post request – Jatin Mehrotra Feb 03 '22 at 02:42

1 Answers1

0

Probably duplicated question. Here is another one:

What does the Ellipsis object do?

It is part of Python, not FastAPI

Srđan Popić
  • 939
  • 12
  • 22