I want to make a FastAPI Post Request to an instance, with this Post Request I want to add a user to a Grafana Organisation. For that, I have to send a post request with the Attributes loginOrEmail
and Role
. But how do I send such a Post Request?
This is the current state of my code.
from fastapi import FastAPI
from pydantic import BaseModel
class User(BaseModel):
loginOrEmail: "user"
role: "Viewer"
app = FastAPI()
app.post("myGrafanaOrganisation http Link")
async def add_user(user: User):
return user
CodePudding user response:
I think you've misunderstood what the app.post decorator is supposed to do; FastAPI is a http api server - not an http client. The argument given to @app.post (the @ is important) is the path of the incoming request. For outgoing requests you can use the requests or aiohttp libraries.