1

I need take this notation as an input, but I couldn't figure out that what should be my input body in fastAPI.

Here is the input structure that is entered from Postman:

[
    {
        "articleUuid": "1",
        "articleContent": "test post matching specific"
    },
    {
        "articleUuid": "2",
        "articleContent": "wregryujtyjyuj"
    }
]

In a nutshell, I need to take each Article Content as below and need process it.

class Article(BaseModel):
    articleUuid: str
    articleContent: str

@app.post("/classify")
async def classification(request: Article = Body(...)):
    print(request.articleContent)
    result = response(request.articleUuid, request.articleContent)
    return result

I tried many bodies. Didn't work out. Could someone help me on that ?

ByUnal
  • 90
  • 1
  • 8

1 Answers1

0
class Article(BaseModel):
    articleUuid: str
    articleContent: str

@app.post("/classify")
async def classification(request: List[Article]):
    ...

Worked for me. I found the solution after a while :)

ByUnal
  • 90
  • 1
  • 8